Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error: String literal is not properly closed by a double-quote

 
Rekha Bhuvanagiri
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
while compiling the jsp in tomcat i got thie error , can anyone resolve it . Thanks in advance..

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 15 in the jsp file: /reg.jsp
String literal is not properly closed by a double-quote
12: "root","root");
13: Statement st= con.createStatement();
14: ResultSet rs;
15: int i=st.executeUpdate("insert into users(user,pwd,fname,lname,email) "+ " values ('"+user+"','"+pwd+"','"+fname+"',
16: '"+lname+"','"+email+"')");
17:
18:


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This means you have a syntax error in the Java code in your JSP.

Modern JSPs should not have any Java code in them. Your best action is to refactor the Java code into a Java class and not in the JSP.
 
Stefan Evans
Bartender
Posts: 1722
10
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And while you're doing that, you can eliminate sql injection vulnerabilities by using a Prepared statement rather than building up a sql string.
The side effect of that will be to simplify your sql string so that you don't need to do string concatenation over multiple lines.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic