File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing a String[] from jsp to servlet" Watch "Passing a String[] from jsp to servlet" New topic

Passing a String[] from jsp to servlet

JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303

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

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

My servlet is in a package 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="" target="_blank" rel="nofollow">I scribble here</a>
Ben Souther

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:
subject: Passing a String[] from jsp to servlet
jQuery in Action, 3rd edition