Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet redirection

 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have login servlet which on validation generate html page(from servlet) with all related user data.
That has two links .
I want that user will go to another servlet or html page with request and response by clicking on link.

Now the problem is if i use <a href> request and responce would not forwarded.
If RequestDispatcher will used how to manage which link is clicked.

I didn't learnt JSP yet
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once the current request and response has been sent to the browser, it's done. What you are asking for is impossible. After the user clicks a link, a new request is generated and there can be no access to the previous request or response.

Why do you feel that you need this access? It's just not how HTTP works, so whatever you are trying to accomplish will need to be satisfied by other means.
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i want something like..

welcome page has update option on it when user will click the link.
there will be all information of current user in editable form.
which on update button will updted to database.

So for fetching all the related option from user i will require the username which i want to forwad.
which was in request parameter of login.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need to remember information from page to page, that is what session scope is for.
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you desrcibe it please !!!

rough code to achieve it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's impossible to write a tutorial on using servlet scopes in a forum post.

You need to work through a servlets tutorial. Learning how to use the session, and other scopes, is a very basic servlets concept that you need to understand before writing servlets.

I suggest starting here.

The basics: get the session from the request instance, set an "attribute" (more properly called a scoped variable) on the session. You can retrieve this value from any request participating in the same session.

 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Bear really appreciate your help.
I am a self-starter trying to learn with online materials.

You make me know by using what i can achieve my thing.
Now i will learn all about session management.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic