Home Answers Viewqa JSP-Servlet How to resolve NumberFormatException(Unlnown Source)?

 
 


dipanjan goswami
How to resolve NumberFormatException(Unlnown Source)?
1 Answer(s)      2 years and 6 months ago
Posted in : JSP-Servlet

I'm using some code where I'm getting NumberFormatException in the code but logically it seem to me perfectly ok because whenever I 'm using that code in .java file it works perfectly ok but when I'm using same type of code in a jsp it throws the exception. Code i'm is some thing like that:`print("<% String t=request.getParameter("time"); /* "time" is the name of the textfield from which I'm getting the value. I also initialized the textfield with value="0000" */ int t1=Integer.parseInt(t); %> ");`

View Answers

November 30, 2010 at 1:08 PM


Hello Friend,

The correct way to get the parameter value is:

<%
try{
String t=request.getParameter("time");
int t1=Integer.parseInt(t);
out.println(t1);
}
catch(Exception e){
    out.println(e);
}
%>

Thanks









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.