Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using a servlet bean in a jsp file

 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I�m working on upgrading all my code to use Struts Tiles Templates. In the code I define some variables, which have to be used by all my jsp pages. Before my udgrading to Struts Tiles Templates I just included a jsp file, where all the variables was defined - i.e.


But now I have to share the variables in a bean request scope.

The way I will share the variables is by using a servlet bean (Initialize.java), which I call in the way below:

<jsp:useBean id="init" class="ini.Initialize" scope="request" />

My big problem is that now I have to change all my code in the jsp pages to use the variables, by calling the variables using the bean id, called init. I have to change my code from:

<%=ressources.getString("toppanel.choose_language")%>

to

<%=init.resources.getString("toppanel.choose_language")%>

That is a lot of work. Are there any way to get around of this problem?
[ June 27, 2005: Message edited by: Jeppe Fjord ]
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give how similar those two pieces of code are, you can just use the Search / Replace function in your IDE. Most IDE's should support this, I know that Eclipse does.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic