• 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

regarding POST method.

 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm reviewing Whizlabs exam, there, I came across that,

POST data can only be read once

. Way is that? What's the impact?

Thanks!
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Abimaran,

I am not sure what they mean exactly, but maybe they refer to the following difference.
Consider a jsp like this:

and a simular jsp with calling the get method:

And a Servlet (with a correct mapping) which just forwards (from the doGet() and the doPost() method) to another jsp where it shows the text fields

If you now refresh the page which was made after a doGet() it just refreshes, but if you refresh the page after a doPost(), the browser will ask you if you want to re-submit your previous data (you can't re-read it)

Regards,
Frits
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Frits, this is the question. I don't know whether it's legal to post that question. Let's see what happens.




The html form accessed in a browser, and the value entered for value1 = 500, and value2 = 600. What will be displayed?

Thanks!
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Abimaran,

I don't know whether it's legal to post that question. Let's see what happens.


As long as you provide the source of the question it is ok for javaranch (with the exception of real exam questions of course).

The html form accessed in a browser, and the value entered for value1 = 500, and value2 = 600. What will be displayed?

Is this also from Whizlabs?

Regards,
Frits
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea, It's from Whizlabs. I mean, this is copyright version, so posting the question would make problem, that's why I asked it. There, they provide solutions, but, I couldn't understand.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
H Abimaran,

The question is testing the following rule:
  • either use the request.getParameter() or the request.getInputStream() to obtain the data being submitted but never use both.

  • Remember that request.getReader() is returning a BufferedReader which is just a wrapper around the InputStream

    Regards,
    Frits
     
    Abimaran Kugathasan
    Ranch Hand
    Posts: 2066
    IntelliJ IDE Clojure Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Frits! Normally, How does the container handles the request and response objects? For response, it's use the ServletOutputStream for writing binary data, and PrintWriter is a convenient way of writing, and PrintWriter is wrapped around ServletOutputStream. But what about request object? I know, there are two objetcts, ServletInputStream and BufferedReader. Defuulty, on which object is used to get the body of the request, such as getAttribute(), getParameter(), etc?

    Thanks!
     
    Frits Walraven
    Creator of Enthuware JWS+ V6
    Posts: 3411
    320
    Android Eclipse IDE Chrome
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    For response, it's use the ServletOutputStream for writing binary data, and PrintWriter is a convenient way of writing, and PrintWriter is wrapped around ServletOutputStream. But what about request object? I know, there are two objetcts, ServletInputStream and BufferedReader. Defuulty, on which object is used to get the body of the request, such as getAttribute(), getParameter(), etc?


    For the request it is simular, you either use the getInputStream() which returns a ServletInputStream (just try it yourself and read the stream) or you use the convenient methods like getParameter() and getAttribute(). (the implementation of these methods probably use the getInputStream as well to obtain the data....)

    Regards,
    Frits
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic