• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

forward not redirect, on click of button

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone,

how can i forward my request to another jsp on click of an OK(Submit) button and to another page on click of a CANCEL(Submit) button.
both these buttons are on the same page.
once again i would like to emphasis on the word forward and not redirect it.
by putting the name in the action attribute it would be redirected to that page but i want to forward it to certain page.

thank you.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't. And that make no sense. What are you really trying to accomplish?
 
Preet Dholabhai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
once i login into my application i don't want the user to go back using the back button.
or take it the other way, once user logout and on a new page i don't want the user to go back into the logged in account which he/she has already logged out from.

now, (pl. correct me if i am wrong) if i use forward this can be done, because the request will be forwarded on the server and the browser will be ignorant of that.
but since i have my submit button on the browser i will have to send the request to the server at least once.
for this i will have to redirect my request atleast once to the server. so i understand, it is not possible to forward the first request you send to the server but you have to redirect it.
But, once on the server i.e. when i logout, request will have reached the server and so it is possible to forward the request. so, my problem is how can i forward the request to another page when i click on the LogOut button.

now here when i refer to the request (in the last point) i am assuming that the request is the same request i sent while logging in.
my assumption will be wrong if every click on the button produces a new request. i think i got it that it is not possible to do what i am trying to do.

pl. guide me if i have understood anything wrong.

thank you.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Preet Dholabhai wrote:my assumption will be wrong if every click on the button produces a new request. i think i got it that it is not possible to do what i am trying to do.


Your assumption is wrong. Each click produces a new request.

There is a "post-redirect-get" pattern that prevents a post from being resubmitted if the user clicks refresh. I think this might be what you are confusing your scenario with. That wouldn't help you here because you are looking to block the page before.

You'll need two techniques:
1) Set http headers to no-cache so the user doesn't see the page before logging out.
2) Check in your application on each page for a logged in user. You can use a servlet filter for this.
 
Preet Dholabhai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you.
 
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I only understood your first post....
I am trying to answer to that .. But looking at other rancher's answer .. for some reason i feel that i am wrong but still ... here it is..

1. i would have created a form with two buttons, with each having a value(1 and 2)
2.And a servlet reads the parameter's value . And depending on the value i can forward the request to different pages


is it correct or i misunderstood the question??
 
Preet Dholabhai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my question was, can i forward a request from the browser?( which i understood after thinking over it for some time and realized it was quite foolish of me to ask such a question because how can i forward a request if it haven't reached the server yet!)

i am doing the same thing you have mentioned i.e. redirecting to pages based on the values of the buttons and regarding the point which i was trying to accomplish(user should not be able to go back to the logged out page using the back button on the browser), i will use the solution provided by Jeanne Boyarsky.

thank you.
reply
    Bookmark Topic Watch Topic
  • New Topic