aspose file tools*
The moose likes Struts and the fly likes how to show javascript alert on struts JSP page based on value entered in form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to show javascript alert on struts JSP page based on value entered in form" Watch "how to show javascript alert on struts JSP page based on value entered in form" New topic
Author

how to show javascript alert on struts JSP page based on value entered in form

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
Hi I want to show an alert in struts JSP page based on value intered in JSP form.


The value entered in Form and in results.jsp I want to check the value and display alert accordingly.This value is available to me in action Form but how to get this in JSP and check and show alert.


<action path="/myAction" type="com.actions.myAction"
name="myForm">
<forward name="success" path="/results.jsp"></forward>

Please advice.

Thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30516
    
150

In your Struts action, you can set that value using request.setAttribute. Then it is available for you to use in JSP.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
Thanks.

In struts JSP we can display any value as <bean:write name="getMytForm" property="myConditionValue" />

problem is how to access this myConditionValue in JSP and put alert based on its value.

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30516
    
150

First, can you write JavaScript code on your JSP that unconditionally displays this value? Then wrap it in a Struts if statement.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
Thanks a lot. That worked fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to show javascript alert on struts JSP page based on value entered in form