Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing a String[] from jsp to servlet

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sravan Kumar
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give the URL mapping that's valid for this servlet as specified in web.xml
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
mohan gavande
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why r u store String[] in attribute??
just use request.getParameters() in servlet from jsp.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic