aspose file tools*
The moose likes Struts and the fly likes Servlet.service() for servlet jsp threw exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Servlet.service() for servlet jsp threw exception" Watch "Servlet.service() for servlet jsp threw exception" New topic
Author

Servlet.service() for servlet jsp threw exception

Latha Sree
Greenhorn

Joined: Apr 07, 2009
Posts: 17
Hi Friends.

Can anyone tell me why I am getting this exception..(This is occurring at times only)
The same code is working fine is another instance with same database and war and jar files..

SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:468)
at java.lang.Integer.parseInt(Integer.java:497)
at org.apache.jsp.aascAjaxShipMethodInfo_jsp._jspService(aascAjaxShipMethodInfo_jsp.java:105)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Latha Sree wrote:
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:468)
at java.lang.Integer.parseInt(Integer.java:497)
at org.apache.jsp.aascAjaxShipMethodInfo_jsp._jspService(aascAjaxShipMethodInfo_jsp.java:105)


No on can help you, if you can not understand what the first few lines of exception trace indicating
Debug or handle the exception.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Richard Blaha
Ranch Hand

Joined: Dec 13, 2007
Posts: 34
I am getting a similar error. The last few lines of my servlet are:

request.setAttribute("skillRecs", skillDataInfoArray);
String dataViewPage="/skilldata.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher( dataViewPage);
if (dispatcher != null){
dispatcher.forward(request, response);

The skillDataInfoArray is an array of Hashmaps with all strings destined for my skilldata.jsp My jsp has code for bringing in the skillRecs data:

<tr>
<td>${requestScope.skillRecs.deleteRec}</td>
<td>${requestScope.skillRecs.company}</td>


My failure output begins as:

ApplicationDispatcher[/MyWebApp] PWC1231: Servlet.service() for servlet jsp threw exception
java.lang.NumberFormatException: For input string: "deleteRec"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at javax.el.ArrayELResolver.toInteger(ArrayELResolver.java:375)

I know what the NumberFormatException is, but do not understand why I am getting it. Would someone please help me as I am new to this form of passing data to a JSP?

Thank you.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

You have correctly identified this EL expression as the source of the problem:



So to find out why it's wrong, you first have to understand what it means. First there's "requestScope"; that identifies a Map of request attributes. Then there's "requestScope.skillRecs"; that uses the string "skillRecs" as a key of the Map and returns the value of your request attribute. Which you say is an array of HashMaps. So far, so good.

Then there's "requestScope.skillRecs.deleteRec", which uses the string "deleteRec" as an index of that array. The first step in that process is converting that string to a number, which as you can see fails. So you're using the wrong EL expression to index an array.

Here's a link to a JSTL tutorial which explains the correct syntax: The JSTL Expression Language.
Richard Blaha
Ranch Hand

Joined: Dec 13, 2007
Posts: 34
OK. My NumberFormatException has been corrected! Thank you for the direction you gave me. My problem is now I get to my JSP, but nothing is displayed in my table except headers and   which I put in to assure that a table row existed where data was suppose to be displayed. I actually have 25 columns that I have successfully mapped to my Hashmap object. I know it contains the data because after I wrote it to the Hashmap I printed it out in my log output. After that I set it to be the request attribute I am attempting to display in my JSP when I forward the reqeust, response to that JSP. In my JSP after the table I have the line:

${requestScope.skillRecs}

outside the table. On my web page is displayed:

{0=com.company.ajax.skillDataInfo@c209ae}

with skilDataInfo being the class for the Object of the skillRecs from the requestScope.

I have based as much as I can from the tutorial I was learning from, but once again I cannot determine the difference in the method of coding.

I would greatly appreciate help here. Thank you.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Okay. So you have a SkillDataInfo object. Presumably you want to use it in some way which is more sophisticated than just its toString() method. You'll have to decide what you want to do with it first -- does it perhaps contain something which you iterate over, or some properties you can get?
Richard Blaha
Ranch Hand

Joined: Dec 13, 2007
Posts: 34
Thank you for your response Paul.

My strategy contains several steps. I take it one step at a time hoping to learn from the mistakes I make, the errors I encounter, and establish a good understanding before moving to the next.

1. As I am following a tutorial my initial step is to at least get my data to display, the toString() concept you mentioned.
2. My second step would be to display more than one row of data as a given employee may have multiple skill sets.
3. Then I need to make some fields editable, but not all.
4. Finally for my data I will have to implement deleting a row, adding a row, and updating a row, and interacting with the database for each of these.
5. Finally for my JSP decorate it to have 'glitter' for the user.

The tutorial I am following is found at: Introduction to Ajax for Web Applications. I downloaded the complete tutorial project after I completed all that was in the tutorial. Then I started transitioning from the tutorial to a prototype for projects.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

That's a good strategy in general, but I don't understand why you are using an AJAX tutorial to help you learn JSTL and the EL. They are basically unrelated topics.
Richard Blaha
Ranch Hand

Joined: Dec 13, 2007
Posts: 34
Hello Paul,

I found my error in my 'toString()' variety. My misunderstanding was I needed to pass in a HashMap containing the SkillDataInfo instead of the SkillDataInfo object itself. I now have 'toString()' display.

Thank you.
Richard Blaha
Ranch Hand

Joined: Dec 13, 2007
Posts: 34
I don't understand why you are using an AJAX tutorial to help you learn JSTL and the EL. They are basically unrelated topics.


I understand. I am learning AJAX. The JSTL and EL were a final step in the AJAX tutorial covering methods with which I am not yet familiar. The tutorial used it and since it wasn't the focus of the tutorial there was no explanation as to how it works. As I asked another, point me to the tutorial that now handles where the tutorial I was using left off.

Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet.service() for servlet jsp threw exception