• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing a String[] from jsp to servlet

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Give the URL mapping that's valid for this servlet as specified in web.xml
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why r u store String[] in attribute??
just use request.getParameters() in servlet from jsp.
 
reply
    Bookmark Topic Watch Topic
  • New Topic