How to Control requestDispatcher in JSP

Iam getting some values from a servlet through getAttribute in a jsp. In Jsp iam setting again some values into another JSP . Iam using requestDispatcher to pass these values in JSP and Servlet.In the second JSP the requestDispatcher should only work when I press the BACK Button, How to acheive this as presently its not showing the back button in JSP itself and directly its executing the requestdispatcher .Iam using JavaScript for BACK Button Functions and have put requestDispatcher statement in that function.

if (chr_xx_Action =="Back")

{

{

<%

String a=(String)request.getAttribute("v_share");

String b=(String)request.getAttribute("v_lot");

System.out.println("JSp a="+a);

System.out.println("JSp b="+b);

request.setAttribute("share",a);

request.setAttribute("lot",b);

RequestDispatcher dispatcher=request.getRequestDispatcher("/checking.jsp");

dispatcher.forward(request,response);

%>

returntrue;

}

[1391 byte] By [amitjavaa] at [2007-10-2 17:51:01]
# 1

You can't mix javascript/Java code in this manner.

Java code runs on the SERVER. It produces an HTML page which gets sent to the browser.

Java stops running.

At this point the only way to run java code again is to click a link/submit a form which makes a new request to the server.

Java code can NOT respond to javascript events - especially not onclick of buttons.

evnafetsa at 2007-7-13 19:09:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Iam satisfied with the answer but please suggest me a solution to acheive this.Thanks in advance
amitjavaa at 2007-7-13 19:09:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Haii

Request dispatcher will transfer ur request to another servlet or jsp from the server side..the point to remember here is server side...

Now how can u expect back button which comes in client to call RD?

u just need to diriectly call ur action on click of back button........

regards

Shanu

mshanua at 2007-7-13 19:09:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...