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 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: You can remove the
// 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;
& Lt; Input type = "text" name = "name" value = "$ {student .name}" />
null values by using the Ternary Operator:
< Code> & lt; Input type = "text" name = "name" value = "$ {empty student?" ": student.name}" />
Comments
Post a Comment