0% found this document useful (0 votes)
67 views3 pages

Taglib Doctype HTML Head Meta Title Title Head Body S:form S:textfield S:textfield S:submit S:submit S:form Body HTML

The document provides instructions for setting up a basic Struts application in Eclipse, including: 1) Creating a dynamic web project called "SampleStruts" and generating the web.xml file. 2) Adding necessary Struts jar files and configuring the web.xml with Struts filter mappings. 3) Creating an index.jsp page with a form to submit a name, along with supporting Java and configuration files like struts.xml and a Result page.

Uploaded by

jabi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views3 pages

Taglib Doctype HTML Head Meta Title Title Head Body S:form S:textfield S:textfield S:submit S:submit S:form Body HTML

The document provides instructions for setting up a basic Struts application in Eclipse, including: 1) Creating a dynamic web project called "SampleStruts" and generating the web.xml file. 2) Adding necessary Struts jar files and configuring the web.xml with Struts filter mappings. 3) Creating an index.jsp page with a form to submit a name, along with supporting Java and configuration files like struts.xml and a Result page.

Uploaded by

jabi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Create dynamic project ->Project Name : SampleStruts -> next ->next-> check mark on (Generate

web.xml deployment ) ->Finish

Goto -> Webcontent folder -> right click -> New-> create JSP file -> File name = index.jsp ->next->Finish

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="sayhello">
<s:textfield name="name" label="Enter your Name :"></s:textfield>
<s:submit value="submit"></s:submit>
</s:form>
</body>
</html>

We have to copy the jar files list

 Commons-io-1.3.2 jar
 Commons –fileupload-1.2.1 jar
 Commons –lang-2. Jar
 Commons-logging-1.0.4 jar
 Commons-logging-api 1.1 jar
 Freemarker 2.3.18 jar
 Javassist-3.0.4 jar
 Ognl-3.0.4 jar
 Struts2-core 2.3.1.2 jar
 Xwork-core 2.3.1.2 jar

Goto web.xml file write as seeing below :

<?xml version="1.0" encoding="UTF-8"?>


<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>SampleStruts</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>Struts2</filter-name>
<filter-
class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-
class>
</filter>
<filter-mapping>
<filter-name>Struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

Create struts.xml file

Goto -> java Resources -> src->right click-create folder name (resources) right click ->new ->other ->goto
xml folder -> click XMLfile ->next -> File name=struts.xml ->net->next ->finish.

<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package name="default" extends="struts-default">
<action name="sayhello" class="com.seconds.sayhello" method="execute">
<result name="success">welcome.jsp</result>
</action>
</package>
</struts>

Create .java class file Ex: sayhello.java

Goto java resource -> src-> right click create java class ->write package name and name ->finish.
=com.seconds.sayhello

package com.seconds;

public class sayhello {


private String name;

public String getName() {


return name;
}

public void setName(String name) {


this.name = name;
}
public String execute()
{
return "success";
}

}
Create welcome.jsp page con Webcontent folder -> right click -> create jsp page

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
My name is :<s:property value="name"/>
</body>
</html>

You might also like