wood burning stoves 2.0*
The moose likes Servlets and the fly likes Passing a String[] from jsp to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing a String[] from jsp to servlet" Watch "Passing a String[] from jsp to servlet" New topic
Author

Passing a String[] from jsp to servlet

JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303
Hi!

I have a jsp page, where I am setting a String[] as a request attribute.
In the corresponding servlet, I say request.getAttribute("key") -> I get Null Pointer Exception.

I tried using RequestDispatcher rd = request.getRequestDispatcher("relative path"); -- line 1
rd.forward(request,response);

After putting the above two lines, the jsp page isnt rendered properly and gives a Translation error.

My servlet is in a package a.b.c.Servlet.java. How do I give this path in line 1.


SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121
Give the URL mapping that's valid for this servlet as specified in web.xml


keep smilin :: sravan<br /><a href="http://sravanpens.blogspot.com" target="_blank" rel="nofollow">I scribble here</a>
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Are you trying to pass the value from the webpage back to the server this way?
How are you getting from your JSP to the servlet?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
mohan gavande
Ranch Hand

Joined: Oct 07, 2004
Posts: 39
why r u store String[] in attribute??
just use request.getParameters() in servlet from jsp.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing a String[] from jsp to servlet