This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to replace requestDispatcher.include() with tags in jsp

 
Abdul Aatif
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,
I have written a two JSP's(one.jsp and two.jsp), One.jsp has a table with 3 text field's and button. If the user clicks on button, the request is sent to two.jsp, and in two.jsp the i am placing some data into request Scope variables and forwarding( using <%@ include file="index.jsp" %>) the request to one.jsp, But the problem is i am unable to get the values stored in request scope in one.jsp. And if i am using requestDispatcher.include() it is working.

so how to replace requestDispatcher.include() with tags in jsp.

===========================one.jsp========================

<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>

</head>
<body bgcolor="lightblue">
<center>
<form action="two.jsp" method="post" name="myForm" >



<table border="1">
<tr><td>deptno</td> <td><input type="text" name="n1" value=${dno} ></td></tr>
<tr><td>deptname</td><td><input type="text" name="n2" value=${dname} ></td></tr>
<tr><td>Loc</td><td><input type="text" name="n3" value=${dloc} ></td></tr>
</table>


<input type="submit" name="submitting" value="first" >
</form>
</center>


</body>
</html>
============================two.jsp===================================


<%@ page isELIgnored="false" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


<%@ include file="one.jsp" %>

<c:set scope="page" var="s" value="${param.submitting}"></c:set>
<c:set scope="page" var="first" value="first"></c:set>



<c:choose>

<c:when test="${pageScope.s == pageScope.first }">

<c:set scope="request" var="dno" value="one" ></c:set>
<c:set scope="request" var="dname" value="one name"></c:set>
<c:set scope="request" var="dloc" value="one sal"></c:set>

</c:when>


<c:when test="${pageScope.s == pageScope.last }">

</c:when>

<c:otherwise>
<c:out value="hmmm" ></c:out>
</c:otherwise>
</c:choose>



========================================================

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problems like this can be solved by following best practices. Submitting a form to a JSP is not the correct way to do things. You should be submitting to a servlet controller. Read this article for more information.

Regardless, request-scoped variables will never be available in a different request.
 
hari vis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try <jsp:include> tag.
 
Abdul Aatif
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Problems like this can be solved by following best practices. Submitting a form to a JSP is not the correct way to do things. You should be submitting to a servlet controller. Read this article for more information.

Regardless, request-scoped variables will never be available in a different request.




Sir, but if i am using

<%
RequestDispatcher rd = request.getRequestDispatcher("one.jsp");
rd.include(requset,forward);
%>

It is working Fine.


 
Abdul Aatif
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hari vis wrote:try <jsp:include> tag.



Sir i have used <jsp:include> to replace requestDispatcher.include() , i am unable to pass request object to another page using JSP TAG'S



Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read ItDoesntWorkIsUseless. SHow us what you are doing and exactly what is happening. Making us guess won't get you much help.
 
hari vis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Latif Khan wrote:
hari vis wrote:try <jsp:include> tag.



Sir i have used <jsp:include> to replace requestDispatcher.include() , i am unable to pass request object to another page using JSP TAG'S



Thanks in advance.


You don't need to pass request objects between JSPs, unlike Servlets. They are implicitly available, use the implicit 'request' object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic