• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Monica Shiralkar
Ranch Hand
Posts: 921
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Sheriff
Posts: 37399
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your Struts action, you can set that value using request.setAttribute. Then it is available for you to use in JSP.
 
Monica Shiralkar
Ranch Hand
Posts: 921
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Sheriff
Posts: 37399
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 921
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. That worked fine.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!