aspose file tools*
The moose likes Struts and the fly likes jsp scriptlet value in struts 2? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "jsp scriptlet value in struts 2?" Watch "jsp scriptlet value in struts 2?" New topic
Author

jsp scriptlet value in struts 2?

prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 132

Hi Ranchers,
Im new to struts 2, I have to use jsp 'scriptlet' value in struts 2 as we use it in struts 1.

Example:
Struts 1: we will use scriptlet vlaue in struts 1 as:
<%
String name = "prabhu";
%>

<a href="action.do?name=<%=name%>"></a>


Struts 2:

Like we use in struts 1 i need to use it in struts 2:
Im using tabbed pane, and in <s iv> tag there is a attribute named 'href'
and i tried to use:
<%
String fromDate = "2006-06-05";
%>

<s:tabbedPanel id="test" >
<s iv href="summary.do?fromDate=<%=fromDate%>" id="one" label="Tab 1" theme="ajax" labelposition="top" ></s iv>
<s iv id="four" label="Tab 4" theme="ajax">
This is the forth panel.
</s iv>
<s iv id="five" label="Tab 5" theme="ajax">
This is the forth panel.
</s iv>
</s:tabbedPanel>

Note: Im using struts 1 action to be called from struts-config.xml file.

Please help me out to use scriptlet values in struts 2 application.

Looking forward for Ranchers reply as early as possible.

Thanks and Regards,
Prabhu.


[ June 10, 2008: Message edited by: Bear Bibeault ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by prabhu rangan:
I have to use jsp 'scriptlet' value in struts 2

Why do you have to use a scriptlet? It's considered bad form to use scriptlets in JSPs anyway. Why not look for an alternative way of doing it? Struts 2 OGNL is flexible enough that I can't see that you'd ever need to use a scriptlet.


Merrill
Consultant, Sima Solutions
prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 132

Hi Meriyl,
Great to share your thoughts. But please shall you provide me any sample code using OGNL, with what my requirement is. Just an sample code so that i can step up easily and can go on my track in time.
Also is it possible to use OGNL with existing struts 1 action class.
For example:
In my action class im setting an attribute in session,

'request.setAttribute("name", name);'

and this attribute that is set in request should be accessed from a jsp page using OGNL as you suggested, please provide me some sample that you have worked out, or your guidance.


Looking forward for your reply.

Thanks and Regards,
Prabhu.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp scriptlet value in struts 2?