0

In the below code i m trying to send my request attribute from req.jsp page to retr.jsp.

i would like to know if we can pass request attributes from one jsp page to other jsp page


the below is my req.jsp

<html>
<head>
hey i m page 1
</head>
<body>
<% request.setAttribute("info from page1", info); %>
<% RequestDispatcher dispatch=request.getRequestDispatcher("/retr.jsp");
dispatch.forward(request,response);
%>
</body>
</html>

this is my retr.jsp

<html>
<head>
i m gettin request from page1
</head>
<body>
<%=request.getAttribute("info")%>
</body>
</html>
2
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by javaAddict
0

I haven't tried that code. You need to check it yourself.

But I would suggest this, if you want to have more chances of succeeding.

<% request.setAttribute("[B]info[/B]", "info from page1"); %>

....

<%=request.getAttribute("[B]info[/B]")%>

Edited by javaAddict: n/a

0

hey it will work in one jsp page..

but i want request attributes to be passed to another jsp page..is it possible??

0

I didn't mean that you put both lines in the same file.
One line goes to one file and the other to the other.
Try your code to see if it works, with the suggestion I gave you.

0

How are you suppose to retrieve the value if you don't execute the page req first. This is where you set the attribute.

You say "i couldnt retrieve from req.jsp page in retr.jsp page "
Of course you didn't . When you opened the retr, you had't put anything in the request. Did you call the req.jsp in order to get the request from?

0

Then I guess it cannot be done that way. You don't need to use that code inside a jsp. You usually do that in a servlet.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.