how to populate java object values in jsp -


I have a scenario like this.

The JSP page is submitted after submitting the request to the sublet. I need to send an object to the JSP page to fill the form text field, as I need in the servlet.

User will enter id value in the form and we need to get data from the database and fill the rest of the fields in the same page

Is used in this process

  // servlet // 1 request.setAttribute ("student", student); // 2 request.getRequestDispatcher ("/ Student.jsp"). Forwarded (request, response); // getAtttibut used here in JSP input type = "text" name = "name" value = & lt;% = name% & gt;   

I have done coding and it is working fine, but it looks very useless!

Please mention any other way to do this task efficiently.

Just tell me how to proceed and I can work for it :)

While your approach type is correct, you should therefore, obtain data from your request attributes:

  & Lt; Input type = "text" name = "name" value = "$ {student .name}" />   

You can remove the null values ​​by using the Ternary Operator:

 < Code> & lt; Input type = "text" name = "name" value = "$ {empty student?" ": student.name}" />    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -