Anda di halaman 1dari 5

AIM: 6.Implement the "Hello World!

" program using JSP Struts Framework PROCEDURE: Step 1:


in tomcat install directory Open tomcat/webapps Create a subdirectory(ts) Copy the struts-blank.war file At that directory path in cmd give the command as Jar xvf struts-blank.war

Step 2:
create a directory (work in e:\) and copy struts.jar,servelet-appi.jar into work d directory.Then set the classpath as set classpath=struts.jar;servlet-api.jar; then copy the ActionOne.class file to webapps/ts/WEB-INF/classes

ActionOne.java:
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import org.apache.struts.action.*; public class ActionOne extends Action { publicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequest request,HttpServletResponse response)throws Exception { System.out.println("---Action executed----"); PrintWriter pw=response.getWriter(); pw.println("HELLO WORLD!"); return null; } }

Step 3: Struts-Config.xml file


<?xml version="1.0" encoding="UTF-8"?> <struts-config> <action-mappings> <action path="/xxx" type="ActionOne"/> </action-mappings> </struts-config>

Step 4: Web.xml
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init--param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!--Standard Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- The Usual Welcome File List --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- Struts Tag Library Descriptors --> <taglib> <taglib-uri>/tags/struts-bean</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/tags/struts-logic</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> <taglib> <taglib-uri>/tags/struts-nested</taglib-uri> <taglib-location>/WEB-INF/struts-nested.tld</taglib-location> </taglib> <taglib> <taglib-uri>/tags/struts-tiles</taglib-uri> <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location> </taglib> </web-app>

Step 5:
then in I.E give the url as http:localhost:8080/ts/xxx.do

Anda mungkin juga menyukai