Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

JSP logic separation  RSS feed

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was thinking about separating my JSP logic into a header.jsp where I have:



Also I was thinking about adding the following code:


The latter is something all my JSP file have. It gives them the first part of the URI to use later in the code /firstPartofURI/newpage

However. I can' get this to work. Because the variable firstPartOfURI is in anoter JSP file which I include I cannot use it in my JSP because it does not know this variable.

Is there a way to work around this?

Also another thing:
In my webpage I have a service selector form which is loaded on startup. When a service is selected that form is shown. And that form is including the service selection form in its JSP. So I run into the problem with duplicate headers. The new form page has its header and when including the service selector form it has its header. This does not go well. Anyone know a way around this?[LIST]
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a single variable that should be common to all JSPs, you should bind it to application scope.
 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved my first problem by replacing <jsp:include..> with <%@ include..>
From from request-time to translation-time..

That way I could access the firstPartOfURI in the page which included it.

What do you mean by binding to application scope?
[ July 11, 2007: Message edited by: Sverre Moe ]
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
binding to application is setting attribute for the application scope.
i.e. something like.
application.setAttribute("firstPartOfURI", Util.getFirstPartOfURI(request));
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!