Cheers!
RSR
Viv Singh wrote:Hi,
I have a problem with the RequestDispatcher:
I have a page: http://localhost:8080/tool/portal/page1.jsp
In this page I have a form which gets posted to a servlet called serv1
This serv1 does some operations and executes the following code:
The problem now is that I get redirected to
http://localhost:8080/supporttool/serv1
rather then to:
http://localhost:8080/supporttool/portal/serv1
What am I doing wrong here?
“Everything should be as simple as it is, but not simpler.” Albert Einstein
Viv Singh wrote:
I dont want to send the message as part of the url as posted before.
“Everything should be as simple as it is, but not simpler.” Albert Einstein
Duc Vo wrote:
Viv Singh wrote:
I dont want to send the message as part of the url as posted before.
You have to use response.sendRedirect() to achieve that, now to pass the message back from servlet, you'll have to use query string on the redirecting uri.
Anyway, why don't you want the client to see the servlet uri?
Duc Vo wrote:You have to use response.sendRedirect() to achieve that
Viv Singh wrote:Hi,
The problem now is that I get redirected to
http://localhost:8080/supporttool/serv1
rather then to:
http://localhost:8080/supporttool/portal/serv1
Sam: Yes this is how it is supposed to work - The URL you see will the servlet URL in the Form and has nothing to do with the RequestDispatcher URL.
The strange part is that your application name changes from http://localhost:8080/tool/portal/page1.jsp to http://localhost:8080/supporttool/serv1. That indeed would be strange!
For some strange reason this works:
resp.sendRedirect("portal/page1.jsp?status="+status);
Sam: Yes strange indeedbecause this is how it is supposed to work
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Bear Bibeault wrote:Make up your mind. Do you want to forward or redirect?
Viv Singh wrote:
I just want to "get back" to page1.jsp and would like to show a message on that page after the request was handled by the servlet.
“Everything should be as simple as it is, but not simpler.” Albert Einstein
Duc Vo wrote:
Viv Singh wrote:
I just want to "get back" to page1.jsp and would like to show a message on that page after the request was handled by the servlet.
I would guess the best option for you know is to use redirect and pass message back to the original page using query string as you did before
Bear Bibeault wrote:
Simply forward to the JSP page as per usual after a servlet controller has finished its task and pass the message invisibly as a request-scoped variable.
Bear Bibeault wrote:
I completely disagree. There's no need for the overhead of a redirect.
“Everything should be as simple as it is, but not simpler.” Albert Einstein
Viv Singh wrote:Hi,
I have a problem with the RequestDispatcher:
I have a page: http://localhost:8080/tool/portal/page1.jsp
In this page I have a form which gets posted to a servlet called serv1
This serv1 does some operations and executes the following code:
The problem now is that I get redirected to
http://localhost:8080/supporttool/serv1
rather then to:
http://localhost:8080/supporttool/portal/serv1
What am I doing wrong here?
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
|