jQuery in Action, 3rd edition
The moose likes JSP and the fly likes Using JSP Code in a variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using JSP Code in a variable" Watch "Using JSP Code in a variable" New topic

Using JSP Code in a variable


Joined: Feb 10, 2006
Posts: 1
Hi, for starters I'll mention that I am new to Java/JSP.

I am trying to store the results of an XSL Tranformation as a variable, but the embedded JSP code in the transformation result is not being evaluated -- it is basically just being spat out as a string.

Does anyone know of a way (with examples, preferably) of having a variable contain markup with executable JSP expressions? The reason I am using a variable is that it's not allowed to write files to the server

For example, the pseudo-code from the XSLT result might be:

<!-- variable in 'head.inc' file, included by many JSPs -->
<td>Hello <%=user%></td>
<td><%if (referringPage='login.jsp'){%>welcome back<% }else{ %>Register<%}%>

This is being developed using RAD for WebSphere.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838


There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

JavaRanch Sheriff

[Asking smart questions] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

As to your question: no. JSP markup is evaluated during the translation phase of the JSP life cycle. Once you reach execution phase, the opportunity for translation is long past.

You might find this article helpful.
[ February 10, 2006: Message edited by: Bear Bibeault ]
I agree. Here's the link: http://aspose.com/file-tools
subject: Using JSP Code in a variable
It's not a secret anymore!