aspose file tools*
The moose likes Servlets and the fly likes Servlet redirection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet redirection" Watch "Servlet redirection" New topic
Author

Servlet redirection

Singh Anisha
Ranch Hand

Joined: May 09, 2012
Posts: 100

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

Joined: Jan 10, 2002
Posts: 61764
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Singh Anisha
Ranch Hand

Joined: May 09, 2012
Posts: 100

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

Joined: Jan 10, 2002
Posts: 61764
    
  67

If you need to remember information from page to page, that is what session scope is for.
Singh Anisha
Ranch Hand

Joined: May 09, 2012
Posts: 100

can you desrcibe it please !!!

rough code to achieve it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

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

Joined: May 09, 2012
Posts: 100

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet redirection