• 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 is an another way of getting the form parametrs from jsps?

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yesterday I faced an interview question which I couldn't answer-

"apart from the getParameter() method for getting the form parameters from the jsps what is an another way of doing it?"

Does anybody know here?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the other methods of (Http)ServletRequest, and you'll see.
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Check the other methods of (Http)ServletRequest, and you'll see.



Thank you Ulf.

This is now the lack of understanding here .
Even though I knew the answer I couldnt understand what exactly he was expecting from me.
I would have been able to give the answer indeed if he would have asked me for other methods in the HttpServletRequest .

I guess this happened with me as I've not come across the other ones frequently. Or what else:mad:?

Anyways thanks Ulf for getting the thing clear .
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Even though I knew the answer I couldnt understand what exactly he was expecting from me.


It's perfectly fine to ask for clarification if a question is not completely clear. Of course, the interviewer won't tell you what, exactly, *he* expects to hear, since that's for *you* to say :-)

I would have been able to give the answer indeed if he would have asked me for other methods in the HttpServletRequest.


That would not have been a good interview question (not that the one that did get asked is all that great, either). Knowing by heart all methods in a class is not a tremendously useful skill if I can just look up the javadocs in 10 seconds.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

not that the one that did get asked is all that great, either



++. I was about to say that.

I was firstly a little bewildered with the question. Another form of input like headers / cookies / inputstreams / inputReaders ? Another method to get parameters ?

If a question is not clear, follow it up with the interviewer and narrow it down.
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And so, what is the final answer to the original question ?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a poor question, but I suspect that the interviewer was fishing for getParameterMap() and its ilk.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another way, if the form uses "POST", would be to use the request's input stream to read the posted data directly from the request's body content, and then parse it into parameter names and values yourself.

You'd need to avoid making any calls to "getParameter" beforehand, as the first such call causes the input stream to be consumed (it retrieves and parses the posted data, and merges it with any request parameters found in the query string - which leaves the input stream already-consumed and at end-of-file).

I can't think off-hand of many situations where this would be worthwhile, but if the request has both posted data and a normal query string this approach does let you access the two sets of parameters entirely separately from each other (even if they both have parameters with the same name) - i.e. retrieve the posted data from the input stream, then use getParameter to retrieve the query string parameters on their own. You could also use this regardless of the request's content type, whereas getParameter only reads posted data if its content type is specifically that expected for posted form data.

At any rate, reading the posted data directly from the input stream is another way to do it, and maybe (just maybe) that's what the interviewer was after.
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you guys.

Next time I'll beware of asking the question to get clarified:-).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic