• Post Reply Bookmark Topic Watch Topic
  • New Topic

extracting information about the previous page from where a current jsp page came  RSS feed

 
sahin sarkar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to implement a system where I have to do almost same processing on a jsp page. The slight differences on the present page is based on whether the current page came from page 1 or page 2. So how can I do this?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "came from" mean? I ask because I can imagine at least two different meanings for that term, so could you explain what that means to you? Perhaps an example would help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not a good way to approach the problem. Knowing "where it came from" would be an example of strong binding and is a poor practice.

Think about it this way for a minute: if you had a Java method that needed to perform slightly different processing in various situations, would you try to find out who called it in order to accomplish that? Of course not. So how would you do it? You'd pass parameters to the method, right? Well, the same approach can be used for a JSP.

From this, though, I predict that you are calling JSPs directly without controllers?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would use the HttpSession to store a "state" parameter when writing a page. That is always under your control. Easily expanded to store an entire "state" history if you like.

If you can't because the user has cookies turned off, use a hidden variable in a FORM.

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!