Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@deepika-jf1ysv • Feb 25, 2011
Hey sookie. What problem are you exactly facing.? -
@sookie-T06sFW • Feb 26, 2011
Hey problem that I am facing is the value that I am adding to header is getting lost in my next page. I need to read that value but i couldn't find it. I have a First.jsp page in which I am adding response like followingDeepika BansalHey sookie. What problem are you exactly facing.?
<%= response.addHeader("hello", "Hello"); %>Now I want to go to my Second.jsp and want to get that value in Second.jsp page header. If I do redirect, this value gets lost. Any idea where I am going wrong in my approach ?
Thanks,
Sookie -
@deepika-jf1ysv • Mar 1, 2011
Sookie you can use the concept of parameters. In one of my projects I used that and it worked fine for me. You can try it.
In first page you use the following code:
<jsp:forward page="second_page.jsp"> <jsp:param name="msg" value="Hello."/> </jsp:forward>Here value of the parameter msg will be set as Hello.
And in the second page, use the following in between the head tags:
<head> String msg=request.getParameter("msg"); </head>You'll get your message in the msg variable.
Another way is that you can attach the values in the html header using '&' sign similar to what as we send values using the 'get' method while submitting the form.
In your above query, you've mentioned that you don't want to use the concept of parameters. Any particular reason for that because I find it a very convenient way.😀 -
@praveenkumar-66Ze92 • Mar 2, 2011
You can also use:
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("your url"); request.addParameter("parameter", "value"); dispatcher.include(request, response);