?
Solved

simple jsp issue

Posted on 2014-08-25
6
Medium Priority
?
269 Views
Last Modified: 2014-09-13
I have a menu link M1  ( action url) .
 when user clicks on this link , it shows a  JSP page ....say A.jsp

However , user can come to this same A.jsp page from other link (action url) as well.

Now my problem is , I want to hide a div element in A.jsp whenever user comes to this A.jsp page by clicking M1 link.

I am stuck right here.....because  I am unable to detect whether user is coming to this A.jsp page via clicking M1 link or through clicking other link.

Please guide.
0
Comment
Question by:cofactor
  • 3
  • 3
6 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 40284254
If the links are on different pages, then you could try using
String referrer = request.getHeader("referer"); 

Open in new window

in A.jsp . If you are using JSTL then use
${header.referer}

Open in new window

in your test attribute.   Alternatively you could add a parameter to each link and then get the parameter in  A.jsp
0
 

Author Comment

by:cofactor
ID: 40284767
>>>Alternatively you could add a parameter to each link and then get the parameter in  A.jsp

Ok. I liked this idea....You know  when clicked it goes to action class ....and  then it goes to A.jsp

Do you want me to set the parameter in request attribute  again  in Action class ?  ( so that it is available in A.jsp )

Please clarify bit more at this step .
0
 
LVL 28

Expert Comment

by:rrz
ID: 40284797
I don't use a framework.   Which one are you using?  Maybe an expert will help you. Please tell us which one.  
Do you want me to set the parameter in request attribute
No, that won't work.  If you are clicking a link, then you sending another request. You could set a session-scoped variable.  Something like
session.setAttribute("cameFrom", "M1")

Open in new window

In A.jsp use ${cameFrom} or session.getAttribute("cameFrom")
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Accepted Solution

by:
cofactor earned 0 total points
ID: 40284810
>>>Please tell us which one.  
Struts 2

>>>>No, that won't work.

session is not a good idea here ...because who will clear this session variable .  I think request will suit here.

You know my other link is basically resides in the A.jsp itself.  Its a search submit button which has the same action url as M1 link.

so ..the story  is ....  user can come to this A.jsp page by clicking M1 link  ...and then user can click on Search button in A.jsp which basically returns the same A.jsp

Problem is ...I am unable to capture whether user is clicking M1 link or clicking Search button to submit form.....both of them calling the same action url.

any thoughts here ?
0
 
LVL 28

Expert Comment

by:rrz
ID: 40284844
I don't do Struts. So I can't give you expert advice.  
Problem is ...I am unable to capture whether user is clicking M1 link or clicking Search button to submit form.....both of them calling the same action url.
Seems to me, my second idea might be the way to go. Why can't you add a parameter to the links?   You should post your code that has the links in it.

 You need a Struts expert here. Maybe you should delete this question and open another question with Struts2 in the title.
0
 

Author Closing Comment

by:cofactor
ID: 40320667
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Don’ts and Dos are two important end products of software testing basics that a tester needs to regard. This article attempts to explain the principles of both.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question