1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

CKEditor and JSP GET problems

Discussion in 'JSP' started by ManifestX, Mar 18, 2010.

  1. ManifestX

    ManifestX New Member

    Joined:
    Mar 18, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I am quite new to JSP, and I am having some troubles. I am using CKEditor with my JSP code. Everything seems to be okay with CKEditor, but it is when I go to save the HTML in the CKEditor's textarea to the DataBase, it fails and I do not see it in the exception. Or possibly it is not allowing the SQL script enter of '<html>....'?

    Name is the name of the file, and template is the html I am inputting into the database, ( i.e. <html><head><body> ).

    Here is a snippet of the rf_data.jsp

    Code:
    <%
     
    String name = request.getParameter("name");
    String editor = request.getParameter("editor1");
     
    try {
    String connectionURL = "jdbc:mysql://localhost/rems"; 
    Connection connection = null; 
    Class.forName("com.mysql.jdbc.Driver").newInstance(); 
    connection = DriverManager.getConnection(connectionURL, "root", "root");
     
    if(!connection.isClosed()){ } 
     
    Statement stmt = connection.createStatement();
    ResultSet rs; 
    String sql = "'INSERT INTO template VALUES ('" + name + "','" + editor + "')";
    rs = stmt.executeQuery(sql);
    connection.close();
     
    } 
    catch (Exception e) 
    {
    out.println(e.toString()); 
    } 
     
    %>
    
    Thanks.
    Manifest
     
  2. ManifestX

    ManifestX New Member

    Joined:
    Mar 18, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I have figured it out.
    It seems that I have to put in &lt; and &gt; for the < and > tags.
    It is not exactly being posted in the database though, but at least I have solved the error I was having.

    Unfortunately there is still an error in the connection. Hmmm.
     
  3. ManifestX

    ManifestX New Member

    Joined:
    Mar 18, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Sorry for tripple posting, but I could not edit.
    Though good news. I have found out my problem.
    The problem was the SQL string, I have fixed it to the following:

    Code:
    String sql = "INSERT INTO template ( name, template ) VALUES ('" + name + "','" + editor +"')";


    Thanks for your help, anyways. :)
     

Share This Page