Hi I'm calling servlet from and i'm sending some data also. but i couldn't get the value from servlet. I got a value "null" only. Code from JSP: <jsp:forward page="/servlet/senthil"> <jsp aram name="prak" value="Prakash"> </jsp:forward> code from Servlet : String gh=req.getParameter("prak"); out.println("Value from JSP "+gh); Check it out and let me know the solution. TIA With regards Prakash
Try this in your jsp file: <FORM METHOD="POST" ACTION="/servlet/senthil"> <INPUT TYPE="TEXT" NAME="prak" VALUE="Prakash"> <INPUT TYPE="SUBMIT" VALUE="Send"> </FORM>
prakash muthu
Ranch Hand
Joined: Sep 06, 2000
Posts: 75
posted
0
Dear Kapil, Thanks for your reply. Your has to work, but what probelm with my code. Is there any error or its totally mistake. let me know the details of how to call a servlet from JSP. with regards Prakash
Kapil Agrawal
Greenhorn
Joined: Nov 03, 2000
Posts: 11
posted
0
Dear Prakash, I should have added little explanation for my recommendation. Well, jsp:forward lets you forward the request to another page. It has a single attribute, page, which consists of a URL. It is not capable of carrying a variable value with it. So, if you need to transfer any value and the value is coming from user input, then a 'form' should serve the purpose. If the value is coming from some internal calculation of some java bean, then you can use jsp:usebean, setProperty and getProperty to modify and retrieve bean properties. Hope it helps.
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
Don't forget that you can also use query parameters in a URL. SO your original example might be re-coded as: JSP:
Hi frank How it will work. It will search like a sevlet class in the name of senthil?prak=prakash. I got a error like that only then what is the use of jsp aram tag. I'm using java webserver 2.0. let me know more details. with regards Prakash
Gopal Rao
Greenhorn
Joined: Jun 06, 2002
Posts: 1
posted
0
Hi Prakash, I am not sure if you ever solved the problem. It is simple: you missed the terminating slash character for the "param" tag. <jsp:forward page="/servlet/senthil"> <jsp aram name="prak" value="Prakash" /> </jsp:forward> I put it after "Prakash" as above and tested it. It works file. Gopal