This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Logical includes  RSS feed

 
Mark Nicholas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Piyush Daiya
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Piyush,
This is what I had in mind, I'll give it a try later.
Thanks
Mark
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!