Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Send it as request attribut when clicking on button a) Set request attrbute in jsp</p> <pre><code>request.setAttribute("thatobject",thatobject); </code></pre> <p>In Servlet retrive it as </p> <pre><code>Thatobject obj = (ThatObject) request.getAttribute("thatobject"); </code></pre> <p>b) Set the object in session <code>session.setAttribute("thatobject",thatobject)</code> and retrive it as </p> <pre><code>Thatobject obj = (ThatObject) session.getAttribute("thatobject"); </code></pre> <p>Oh my mistake Updated...</p> <p><strong>Note:</strong> Also iam not providing null check. I think you can handle it</p> <p><strong><em>Edit:</em></strong></p> <p>Even you can do other way, which is very sofistiacted way, </p> <p>a) Create a Bean class<br> b) provide Object as a attribute in bean class and provide getter and setter methods too<br> C) in jsp use that bean to set the object when the page is submitting to servlet<br> d) retrive the object from the bean in servelt <br></p> <p><strong>Edit 2:</strong></p> <p>Please check this link there is clear explanation. <a href="http://docs.oracle.com/cd/A97336_01/buslog.102/a83726/basics4.htm#1014142" rel="nofollow noreferrer">JSP2Servlet</a></p> <p><strong><em>Edit 3</em></strong></p> <p>Note : <strong>If you are submiting form , the request becomes new request and the object will become null, when you use request.getattribute in servlet. So above approach will not work on Form submit in jsp.</strong></p> <p>So to overcome this please folw the instructions provide in below link</p> <p><a href="https://stackoverflow.com/questions/4253660/passing-object-from-jsp-to-servlet">Passing Object from JSP to Servlet</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload