Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

forwarding in url  RSS feed

 
ashok ganesan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

in servlets for forwarding to another web page i use either sendRedirect method or forward method but the result is returned to the same page what should i do if a new a page has to be opened and result being displayed in the new page.


regards and thanks

ashok
 
Vivek tcs
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Put the response.sendRedirect("/....."); in a
try{
}catch
block and use printStackTrace() to get all the errors and do accordingly.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ashok ganesan:

in servlets for forwarding to another web page i use either sendRedirect method or forward method


No, you can only use the request dispatcher forward() method to perform a forward. A redirect is a diferent means of transferring control and is not a "forward".

but the result is returned to the same page


What do you mean by that? Is the forward or redirect not working?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Vivek tcs",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
William Janssen
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I guess you mean that the result should be shown in a new browser (window). In that case it is not controlled by the server but has to be configured in the calling html page.
e.g. in case you are submitting a page you can change the target attribute of the form or anachor element.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a good insight William.

ashok, by

result being displayed in the new page.


Did you mean "new window"?

If so, then William is correct. That is something you control on the client.
 
ashok ganesan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to William Janssen

ok that could be done if i m using <a href=".."> atrribute but what if my using form atrribute.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!