File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes http 500 with stack trace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "http 500 with stack trace" Watch "http 500 with stack trace" New topic
Author

http 500 with stack trace

Peyyety Avinash
Greenhorn

Joined: Mar 25, 2010
Posts: 19
The html code : page2.html


The Request Dispatcher Servlet


The page4.jsp: (not much jsp )



And Finally! the Error:


Please Help..I am a Novice
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
Whats the input that you gave in the html?
Peyyety Avinash
Greenhorn

Joined: Mar 25, 2010
Posts: 19
In box 1: the string "avinash" (without quotes)
In box 2: the string "twenty" (without quotes)

Thanks !
Smitesh Shinde
Ranch Hand

Joined: Feb 16, 2008
Posts: 45




You are trying to convert string "avinash" that you have entered in Name textbox on page2.html to an int inside your servlet. That's why you are getting java.lang.NumberFormatException. And you are going to get similar exception for Age

Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
Parse need numeric IN THE string .
Please read API
Peyyety Avinash
Greenhorn

Joined: Mar 25, 2010
Posts: 19
But, I have to parseInt it to make the addition possible. If i am not using String Buffer
then ..how do i do it.
If only the sum of those two strings combination is to be set as the request Attribute ?
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
How do you want to set the attribute value ??
Is it like
avinsh20
or
avinshtwenty
Peyyety Avinash
Greenhorn

Joined: Mar 25, 2010
Posts: 19
avinashtwenty yes !
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
IaM yOgI wrote:avinashtwenty yes !

Then why are you doing that parseInt thing???
just do this !!
String s1=request.getParameter("Name");
String s2=request.getParameter("Age");
String S=s1+s2;
request.setAttribute("nn", S);
Peyyety Avinash
Greenhorn

Joined: Mar 25, 2010
Posts: 19
I am a thick head, dint know strings can be added ! thought only buffer and builder had such privileges
but what if i wanted it avinash20 way? then i parseInt ?

Thanks ! its working fine
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
IaM yOgI wrote:but what if i wanted it avinash20 way? then i parseInt ?

Then you need to input as "20" And use the parseInt method for the Age input .
Please read the API that i pointed out. It gives better understanding.
Peyyety Avinash
Greenhorn

Joined: Mar 25, 2010
Posts: 19
will do that. thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You only need to parse if you're actually adding numbers. If you're adding "avinsh" and "20" there's no reason to parse, because "avinsh" isn't a number.
Peyyety Avinash
Greenhorn

Joined: Mar 25, 2010
Posts: 19
You only need to parse if you're actually adding numbers. If you're adding "avinsh" and "20" there's no reason to parse, because "avinsh" isn't a number.


Yaa Got it !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: http 500 with stack trace