• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

http 500 with stack trace

 
Peyyety Avinash
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whats the input that you gave in the html?
 
Peyyety Avinash
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In box 1: the string "avinash" (without quotes)
In box 2: the string "twenty" (without quotes)

Thanks !
 
Smitesh Shinde
Ranch Hand
Posts: 45
Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Parse need numeric IN THE string .
Please read API
 
Peyyety Avinash
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you want to set the attribute value ??
Is it like
avinsh20
or
avinshtwenty
 
Peyyety Avinash
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
avinashtwenty yes !
 
Sony Agrawal
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
will do that. thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic