About the use of IncludeAction in struts -
i trying use include action class in struts, not able do....the steps did follows
step 1 : first created presentation page, is
welcome.jsp
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> <html> <head> <title>include example</title> </head> <body> <div align="center"> <bean:include id="bid" forward="logins" /> </div> </body> </html>
step2: created servlet class, passed msg in client page
showservlet.java
package com.ashish.struts.servlet; import java.io.ioexception; import javax.servlet.requestdispatcher; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import com.ashish.struts.loginform; public class showservlet extends httpservlet { private static final long serialversionuid = 1l; public void service(httpservletrequest request, httpservletresponse response)throws ioexception,servletexception { system.out.println("now m in servlet class!!!!"); string msg="this login page"; request.setattribute("msg", msg); requestdispatcher rd= request.getrequestdispatcher("/index1.jsp"); rd.forward(request, response); } }
index1.jsp
<%@ page iselignored="false" %> <html> <head> <title>include example</title> </head> <body> <div align="center"> ${msg } </div> </body> </html>
step3: configured struts-config.xml file
<?xml version="1.0" encoding="utf-8"?> <!doctype struts-config public "-//apache software foundation//dtd struts configuration 1.3//en" "http://struts.apache.org/dtds/struts-config_1_3.dtd"> <struts-config> <form-beans> <form-bean name="log" type="com.ashish.struts.loginform" /> </form-beans> <global-exceptions /> <global-forwards> <forward name="logins" path="/logs1.do" /> </global-forwards> <action-mappings > <action path="/logs1" name="log" type="org.apache.struts.actions.includeaction" parameter="/web-inf/classes/com/ashish/struts/servlet/showservlet" /> </action-mappings> <message-resources parameter="com.ashish.struts.applicationresources" /> </struts-config>
is there things wrong did , in above steps or left things .....
because whenever run application , no error showing , desired output not coming...
can 1 give answer ...
thanks ashish....
you have add <bean:write name="bid" />
in welcome.jsp @ location want display it.
note: <bean:include id="name"... />
should have accompanying <bean:write name="name" />
print output message.
Comments
Post a Comment