Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

passing parameter from JSP to servlet

Thread view: 
Krish - 05 Nov 2006 18:50 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.