• 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

Logical includes

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an JSP include question: Imagine you have 4 JSP's a.jsb, b.jsp, c.jsp each of which include the menu file m.jsp. In m.jsp are links to a,b,c jsp.
However in good UI design the page your actually on should have it's link disabled. Hence my question: a.jsp includes m.jsp, but is it possible for the included m.jsp to 'know' which file it is being included in ?
Mark
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can have a variable in 'a.jsp' like this:
a.jsp

and then in 'm.jsp' you can validate on the valus of 'pageId'.
/Rene
[ July 22, 2002: Message edited by: Rene Larsen ]
 
Mark Nicholas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I was just wondering if it could be achieved without setting a variable, but that method would certainly work.
Cheers
Mark
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Im not sure this will work or not, but u can try it.
In the m.jsp, u can put an if condition to check which file is it being called in by and the accordingly disable the link in m.jsp.
u can use request.getRequestURI() to get the whole path of the file called and request.getContextPath() to get the folder where the called file is stored.
here is example.
let us assume that a.jsp includes m.jsp and a.jsp is stored in /its folder from root.
then request.getRequestURI() will return /its/a.jsp
and
request.getContextPath() will return /its
perform string operations on the return string to get the file called i.e.
fileCalled =replace(request.getRequestURI(),request.getContextPath(),"");

replace function is not standard string function, u will have to write it or u can get it by downloading StringHelper class from http://ostermiller.org/utils/StringHelper.html
then check if fileCalled = a.jsp then disable link for a.jsp etc.
Let me know, if it was helpful.
Im in hurry now,
if u want i can help u with code later.
Regards,
Piyush
 
Mark Nicholas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Piyush,
This is what I had in mind, I'll give it a try later.
Thanks
Mark
 
Your mother is a hamster and your father smells of tiny ads!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic