how can i pass parameter from JSP to servlet
/////in the JSP ////
<%String filechoice="1";
request.setAttribute("filechoice",filechoice); %>
//////in the servlet///
(String)request.getAttribute("filechoice"))
But I am getting null exception error....I am new to JAVA....need help
Daniel Pitts - 05 Nov 2006 22:36 GMT
> how can i pass parameter from JSP to servlet
> /////in the JSP ////
[quoted text clipped - 6 lines]
>
> But I am getting null exception error....I am new to JAVA....need help
I'm not really sure of your design, but a JSP is a Servlet itself, so
unless they are processing the same request, then they don't really
communicate with eachother. the request attributes are only set for
one request (in otherword, one page load from the client).
Arne Vajhøj - 05 Nov 2006 22:50 GMT
> how can i pass parameter from JSP to servlet
> /////in the JSP ////
[quoted text clipped - 6 lines]
>
> But I am getting null exception error....I am new to JAVA....need help
First: it is a very unusual setup. Passing parameters from
servlet to JSP are way more common.
Second: it will only work using the request object if the
JSP page forward to the servlet.
All other usages would require usage of session instead of request.
Arne
Shanmuhanathan T - 06 Nov 2006 11:44 GMT
Krish said,on 06/11/2006 12:20 AM:
> how can i pass parameter from JSP to servlet
> /////in the JSP ////
[quoted text clipped - 6 lines]
>
> But I am getting null exception error....I am new to JAVA....need help
Instead of passing parameters, try using
request.getsession().setAttribute().
This would put the values in the session
for further processing.
if you still want the request to hold it, then you
would have to do a forward(), with the same request
object.
Rgds,
Shanmu.

Signature
Crime does not pay ... as well as politics.
-- A. E. Newman