• 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

What sort of methods are under request.*?

 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'd like to write a general servlet to get the contents of forms in my application, then send those on to a bean to be added to the database. When I say general, I mean that, rather than writing a servlet specific to each jsp I have, I'd lke to use one for all of them. As far as I can see, this would only work if there's a method in request that can loop through all the elements in a form, like the DOM would be able to. Does request have such a method?
Are there any other suggestions for pulling this off? Or should I just bite the bullet and write a servlet for each form?
Thanks,
g.
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's your new best friend, the Servlet 2.3 API:
http://java.sun.com/products/servlet/2.3/javadoc/index.html - it tells you all the possible methods you can call on an object.
If you click "Servlet Request"
you'll see a method called:

getParameterNames
public java.util.Enumeration getParameterNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Enumeration.
Returns:
an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters


You can loop through the enumeration and call getParameter() on each of the parameter names.
Hope that helps!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic