Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error in JSP code  RSS feed

 
sayan maity
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have written a JSP page as follows.

<%@ page language="java" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.lang.Integer" %>
<%@ include file="DBConnection.jsp" %>

<html>
<body>

<%
int userId = Integer.valueOf(request.getParameter("userId")).intValue();
String password = request.getParameter("password");
ResultSet resultSet = statement.executeQuery("select user_id, password, user_name from userdetails");
while (resultSet.next()) {
int userIdTemp = resultSet.getInt("user_id");
String passwordTemp = resultSet.getString("password");
String userNameTemp = resultSet.getString("user_name");
if (userIdTemp == 91922) {
if (password.equals(passwordTemp)) {
%>
<strong>
Welcome <%=userNameTemp%>
</strong>

<% } else {
%>

<strong>
Please try again. Password is wrong
</strong>

<% }
} else {
%>
<strong>
Please try again. User ID doesn't exist.
</strong>
<% }
}
%>
</body>
</html>


But while trying to run it is giving the following error.

16:20:42,534 ERROR [[jsp]] Servlet.service() for servlet jsp threw
exception
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 9 in the jsp file: /SuccessfulLoginPage.jsp
Generated servlet error:
statement cannot be resolved


at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErro
rHandler.java:84)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher
.java:328)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java
:397)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext
.java:556)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:293)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(Applica
tionDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD
ispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis
patcher.java:301)
at LoginServlet.doPost(LoginServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
at java.lang.Thread.run(Thread.java:534)
16:20:42,534 INFO [STDOUT] org.apache.jasper.JasperException: Unable to compile
class for JSP

An error occurred at line: 9 in the jsp file: /SuccessfulLoginPage.jsp
Generated servlet error:
statement cannot be resolved
16:20:42,534 INFO [STDOUT] at org.apache.jasper.compiler.DefaultErrorHandle
r.javacError(DefaultErrorHandler.java:84)
16:20:42,534 INFO [STDOUT] at org.apache.jasper.compiler.ErrorDispatcher.ja
vacError(ErrorDispatcher.java:328)
16:20:42,534 INFO [STDOUT] at org.apache.jasper.compiler.JDTCompiler.genera
teClass(JDTCompiler.java:397)
16:20:42,534 INFO [STDOUT] at org.apache.jasper.compiler.Compiler.compile(C
ompiler.java:288)
16:20:42,534 INFO [STDOUT] at org.apache.jasper.compiler.Compiler.compile(C
ompiler.java:267)
16:20:42,534 INFO [STDOUT] at org.apache.jasper.compiler.Compiler.compile(C
ompiler.java:255)
16:20:42,534 INFO [STDOUT] at org.apache.jasper.JspCompilationContext.compi
le(JspCompilationContext.java:556)
16:20:42,534 INFO [STDOUT] at org.apache.jasper.servlet.JspServletWrapper.s
ervice(JspServletWrapper.java:293)
16:20:42,534 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.serviceJ
spFile(JspServlet.java:314)
16:20:42,534 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.service(
JspServlet.java:264)
16:20:42,534 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpSe
rvlet.java:810)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterCha
in.internalDoFilter(ApplicationFilterChain.java:252)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterCha
in.doFilter(ApplicationFilterChain.java:173)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationDispatche
r.invoke(ApplicationDispatcher.java:672)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationDispatche
r.processRequest(ApplicationDispatcher.java:463)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationDispatche
r.doForward(ApplicationDispatcher.java:398)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationDispatche
r.forward(ApplicationDispatcher.java:301)
16:20:42,534 INFO [STDOUT] at LoginServlet.doPost(LoginServlet.java:37)
16:20:42,534 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpSe
rvlet.java:717)
16:20:42,534 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpSe
rvlet.java:810)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterCha
in.internalDoFilter(ApplicationFilterChain.java:252)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterCha
in.doFilter(ApplicationFilterChain.java:173)
16:20:42,534 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilte
r.doFilter(ReplyHeaderFilter.java:81)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterCha
in.internalDoFilter(ApplicationFilterChain.java:202)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterCha
in.doFilter(ApplicationFilterChain.java:173)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve
.invoke(StandardWrapperValve.java:213)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve
.invoke(StandardContextValve.java:178)
16:20:42,534 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipal
Valve.invoke(CustomPrincipalValve.java:39)
16:20:42,534 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssocia
tionValve.invoke(SecurityAssociationValve.java:153)
16:20:42,534 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValv
e.invoke(JaccContextValve.java:59)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.in
voke(StandardHostValve.java:126)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.i
nvoke(ErrorReportValve.java:105)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.
invoke(StandardEngineValve.java:107)
16:20:42,534 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.s
ervice(CoyoteAdapter.java:148)
16:20:42,534 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.proc
ess(Http11Processor.java:856)
16:20:42,534 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http1
1ConnectionHandler.processConnection(Http11Protocol.java:744)
16:20:42,534 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.pr
ocessSocket(PoolTcpEndpoint.java:527)
16:20:42,534 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerT
hread.run(MasterSlaveWorkerThread.java:112)
16:20:42,534 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)


I am using JBOSS as my server.

Thanks,
Sayan Maity
 
Vasudevan Badri
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this the file Sucessfullogin.jsp. Or do have another file by that name. Would be helpful if you could post that info.

Cheers Vasu
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!