Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help!!! with jsp

Status
Not open for further replies.

ghani

Programmer
Joined
Apr 2, 2001
Messages
2
Location
EU
Hello there Sir

the problem is whenever i m executing the .jsp file in my browser by writting it is giving me an External Servlet Exception message and the exception follows like this:


**********************************************************

javax.servlet.ServletException: null
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:481)
at _0002fSimpleJSP_0002ejspSimpleJSP_jsp_0._jspService(_0002fSimpleJSP_0002ejspSimpleJSP_jsp_0.java:73)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:181)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:393)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:251)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:196)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2038)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.valves.ValveBase.invokeNext(ValveBase.java:242)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:414)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:975)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:159)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:811)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:890)
at java.lang.Thread.run(Thread.java:484)

----- Root Cause -----

java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:373)
at java.lang.Integer.parseInt(Integer.java:454)
at _0002fSimpleJSP_0002ejspSimpleJSP_jsp_0._jspService(_0002fSimpleJSP_0002ejspSimpleJSP_jsp_0.java:53)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:181)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:393)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:251)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:196)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2038)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.valves.ValveBase.invokeNext(ValveBase.java:242)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:414)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:975)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:159)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:977)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:811)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:890)
at java.lang.Thread.run(Thread.java:484)

********************************************************

i m trying to execute the jsp file for about 1 month and i still dont know what is wrong. Cause my Tomcat is running just fine i have put all the variable setting in the autoexec.bat file

like

SET JAVA_HOME=C:\JDK1.3
SET CLASSPATH=C:\JDK1.3\LIB\TOOLS.JAR
SET TOMCAT_HOME=C:\TOMCAT

CAN U PLEASE HELP ME WITH THIS PROBLEM I M VERY KEEN TO LEARN HOW TO PROGRAM IN JSP.

THANKYOU
 
Let's see your code...
 
here is my code

this is Simple.html
***********************************************************
<html>
<body>

<p>How many times</p>

<form method=&quot;GET&quot; action=&quot;Simple.jsp&quot;>
<input type = &quot;text&quot; size = &quot;2&quot; name = &quot;numtimes&quot; >
<inut type =&quot;submit&quot;>
</form>
</body>
</html>
************************************************************


and now this is Simple.jsp

***********************************************************
<@% page language=&quot;java&quot; %>


<html>
<body>

<p><% int numTimes = Integer.parseInt(request.getParameter(&quot;numtimes&quot;));
for(int i=0;i<numTimes;i++){

%>

<% }
%>
</p>


</body>
</html>

***********************************************************

now i have saved both of theses files in the webaps\root of tomcat and i dont now why it is not working

it is just a simple program

thanx

 
Hi,

Couple of things wrong with this ...

Firstly the structure is wrong and you have '%>' tags and '}' tags in the wrong place.

Secondly, the reason you're getting 'null' when you call it with is because in your code you are expecting a parameter to be passed in called numtimes which has to be an integer:

Code:
int numtimes... getParameter(&quot;numtimes&quot;);

If this parameter is not passed in, it tries to store null in an int which throws an exception before you can trap it. Try and then your for..loop will iterate 5 times.

Here is an example for you which should explain what you're doing wrong:

Code:
<% String param = request.getParameter(&quot;numtimes&quot;);

   int NumTimes = 0;

   if(param != null) {
	NumTimes = Integer.parseInt(param);
	for(int i=0;i<NumTimes;i++){   
	  out.print(i);
         }
   } else {
	out.print(&quot;You must specify the numtimes parameter!&quot;);
   }
%>

Bye for now,

Tiz --
Tim <tim@planetedge.co.uk>
 
It looks to be an error when you attempt to parse an int from the form parameter

try this:

try {
int numTimes = Integer.parseInt(request.getParameter(&quot;numtimes&quot;));
}
catch(NumberFormatException fx) {
// error parsing the string
out.println(&quot;Error while attempting to parse int from string&quot;);
}
I hope this helped! ;-)
- Casey Winans
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top