• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts problem

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,

This is prashanth,I am facing some problem while doing struts application using messages tag in jsp.
i am using struts 1.2 version.
Mycode is given bellow....
********struts-config.xml*********
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
<form-beans>
</form-beans>

<action-mappings>
<action path="/mess" type="com.cts.ErrorAction" >
<forward name="go2jsp" path="/erromess.jsp"/>

</action>
</action-mappings>
<message-resources parameter="errorinfo"/>
</struts-config>
***ErrorAction.java*******
package com.cts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
public class ErrorAction extends Action {
public ActionForward execute(ActionMapping map,ActionForm form,HttpServletRequest req,HttpServletResponse res)throws Exception{
System.out.println("execute");
// ActionMessage mes=new ActionMessage("name.required");
// ActionMessage mes1=new ActionMessage("id.required");
// ActionMessage mes2=new ActionMessage("id.integer");
ActionMessages message=new ActionMessages();
message.add("pmes1",new ActionMessage("id.integer"));
saveMessages(req, message);
System.out.println("end of execute");
return map.findForward("go2jsp");

}

}
******erromess.jsp********
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<html:html>
<body>
<html:messages property="pmes1" id="msg" message="false">
<li><bean:write name="msg"/></li>
</html:messages>
</body>
</html:html>
*****errorinfo.properties****
id.integer=not integer
************
Actuvally i need output not integer in browser,but it is not displaying any meaasage ,only blank screen showing.
if any one knows this problem ,please assist me .
bye
message.only blank screen
 
Ranch Hand
Posts: 137
Hibernate Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code seems miising an ActionForm which is required to output the value bind to a property.Try declaring the same property as an ActionForm member and associate the action with the above ActionForm.Nest your <html:messages> tags within <html:form>.
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic