Punit Jain wrote:by using request.getParameter();
Piyush Mangal wrote:
JSP
<tr>name="<%= request.getAttribute("Name") %>"</tr>
<tr>secn="<%= request.getAttribute("SECN") %>"</tr>
<tr>title="<%= request.getAttribute("TITLE") %>"</tr>
Bear Bibeault wrote:
Piyush Mangal wrote:
JSP
<tr>name="<%= request.getAttribute("Name") %>"</tr>
<tr>secn="<%= request.getAttribute("SECN") %>"</tr>
<tr>title="<%= request.getAttribute("TITLE") %>"</tr>
Bad practice! Scriptletes in a JSP has been discredited for 10 years! A whole decade! Do you not think it's time to catch up? :rolleyes:
Use the EL and JSTL, not Java scriptlets.
For example: <c:out value="${name}"/>
pravin venkat wrote:JSTL Implementation
pravin venkat wrote:then, i think these two code abstracts will do the job..
Piyush Mangal wrote:
pravin venkat wrote:then, i think these two code abstracts will do the job..
Ideally Servlet should be responsible for setting the attribute in Request or Session scope based on the use case and forward the request to jsp.
JSP should only use EL to display them on screen.
Piyush Mangal wrote:
All I am saying is that the above code is incorrect and redundant. You can always set attributes in session scope through your controller and dispatch the request to JSP.
Piyush Mangal wrote:
All I am saying is that the above code is incorrect and redundant. You can always set attributes in session scope through your controller and dispatch the request to JSP.
pravin venkat wrote:if possible will you be able to example code?
Piyush Mangal wrote:
It is a bad practice to put sql statement in JSP itself. We should follow MVC architecture where JSP should only be used for displaying values only and not be responsible for fetching it from database directly.
Bear Bibeault wrote:
pravin venkat wrote:if possible will you be able to example code?
If the scoped variable Name is present in request scope, it can be displayed with one of:
${Name}
or
<c:out value="${Name}"/>
depending upon whether HTML-encoding is needed or not (to protect against XSS attacks).
No <c:set> tags are needed.
Piyush Mangal wrote:
All I am saying is that the above code is incorrect and redundant. You can always set attributes in session scope through your controller and dispatch the request to JSP.
Piyush Mangal wrote:Hi Pravin, Please find below the sample code. Please note that this is not complete code and is only for your understanding.
JSP
Servlet
Enjoy the full beauty of the english language. Embedded in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|