Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


dipanjan goswami
How to resolve NumberFormatException(Unlnown Source)?
1 Answer(s)      3 years and 11 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); %> ");`


Advertisement
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 Tutorials/Questions & Answers:
 

 

 

DMCA.com