aspose file tools*
The moose likes Servlets and the fly likes Exception in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Exception in Servlet" Watch "Exception in Servlet" New topic
Author

Exception in Servlet

Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

Hi all,
Why do i get following exception? (The Servlet compiles fine)


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.ex.web.Topla.doPost(Topla.java:15)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.11 logs.

And the servlet is:
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

If there is no sayi1 parameter in the request, then request.getParameter("sayi1") returns null. Since converting null to an int is meaningless, Integer.parseInt(sayi1) throws that exception.

You should put some logic in that code that does things differently if there is no sayi1 (or no sayi2) parameter in the request.
Caine Lai
Greenhorn

Joined: Sep 21, 2005
Posts: 15
Such as:

[ December 22, 2005: Message edited by: Caine Lai ]

Online collaboration made simple: <a href="http://www.rallypointhq.com" target="_blank" rel="nofollow">http://www.rallypointhq.com</a>
Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

i made a typo in html file so that the servlet can not get the parameters from the request.
Dummy mistake:

...
Number 1: <input type="text name="sayi1"><br>
Number 2: <input type="text name="sayi2">
...

Thanks for the replies.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in Servlet