You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Biswas, Goutam_Kumar" <Go...@deshaw.com> on 2003/09/22 12:59:15 UTC

newbie jasperException

Hi,
I am getting the following JasperException. (Please scroll below for the
exception :-) ). I am relatively new to jsp. Can anyone please point me as
to what's going wrong here?

FYI  I am including the jsp code also.
<-----------------jsp code------------------------>
<html>
<head>
<script type="text/javascript">
   function textSelected()
    {
 
option=document.forms[0].PoRefno.options[document.forms[0].PoRefno.selectedI
ndex].text
        document.write("This is the selected text" + option)
    }
</script>
</head>
<body>

<%@ page
import="deshaw.fats.collection.database.PurchaseOrderDbCollection,
java.util.*,java.sql.SQLException"%>
<%! Vector v; %>
<%
	try{
	v=new PurchaseOrderDbCollection().getPoRefNos();
	}
	catch(SQLException e)
	{  %> 
	<jsp:forward page="Errorpage.jsp">
	<jsp:param name="ErrornName" value="SQLException"/>
	<jsp:param name="Location" value="new PurchaseOrderDbCollection()"/>
	</jsp:forward> 
<%      }   %>
<select name="PoRefno" size="5" onchange="textSelected()">
<% 
Iterator i=v.iterator();	
String s;	
while(i.hasNext()) { 
	s=(String) i.next();
	out.write("<option value=\"" + s + "\">" + s + "<br>");
}  
%>

</select>
</form>
</body>
</html>
</---------------jsp code----------------->

type Exception report
message 
description The server encountered an internal error () that prevented it
from fulfilling this request.
exception 
org.apache.jasper.JasperException
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
54)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2408)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:171)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:392)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:619)
	at java.lang.Thread.run(Thread.java:534)
root cause 
javax.servlet.ServletException
	at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:536)
	at
org.apache.jsp.Procurement_jsp._jspService(Procurement_jsp.java:84)
	at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
10)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2408)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:171)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:392)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:619)
	at java.lang.Thread.run(Thread.java:534)

Apache Tomcat/4.1.27


-Goutam



Re: newbie jasperException

Posted by Christopher Williams <cc...@ntlworld.com>.
Hi,

Your JSP code is wrong.  The <%@ page import... %> directive needs to go at
the top of the page.  When the Jasper compiler turns it into Java, that
directive gets turned into one or more Java import statements, and you
wouldn't stick those in the middle of your code.

Remember, all the HTML gets turned into Java code, as follows:
    out.write("<html>\r\n<head>\r\n...");
So that your import statements (and the class variable declaration "<%!
Vector v; %>") appear inside a servlet doGet() method, which is illegal
Java.  In spite of the superficial similarities, JSP is not really like PHP.
The PHP interpreter turns embedded PHP code into HTML, while the JSP
compiler turns HTML into Java (and then the Java compiler turns it into byte
code).  It will help you to keep this in mind when writing JSP code.

BTW, I'm a little troubled by that "<%! Vector v; %>" declaration.  This
turns v into an instance variable of the servlet class that Jasper creates.
Is this what you intended?  If not, remove the exclamation mark and leave
the variable declaration where it is.

Kind regards,

Chris Williams.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: newbie jasperException

Posted by Christopher Williams <cc...@ntlworld.com>.
Hi,

Your JSP code is wrong.  The <%@ page import... %> directive needs to go at
the top of the page.  When the Jasper compiler turns it into Java, that
directive gets turned into one or more Java import statements, and you
wouldn't stick those in the middle of your code.

Remember, all the HTML gets turned into Java code, as follows:
    out.write("<html>\r\n<head>\r\n...");
So that your import statements (and the class variable declaration "<%!
Vector v; %>") appear inside a servlet doGet() method, which is illegal
Java.  In spite of the superficial similarities, JSP is not really like PHP.
The PHP interpreter turns embedded PHP code into HTML, while the JSP
compiler turns HTML into Java (and then the Java compiler turns it into byte
code).  It will help you to keep this in mind when writing JSP code.

BTW, I'm a little troubled by that "<%! Vector v; %>" declaration.  This
turns v into an instance variable of the servlet class that Jasper creates.
Is this what you intended?  If not, remove the exclamation mark and leave
the variable declaration where it is.

Kind regards,

Chris Williams.