Saturday, August 4, 2012

STRUTS 2 programs 007 Plain Text Result

index.jsp
----------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Index Page</TITLE>
</HEAD>
<BODY bgcolor="lightblue"><br clear="all"/><br clear="all"/>
<h2>Index</h2>
<font color="green" face="modern" size="4">
<ul>
<li>View the <a href="rawData.action">JSP</a> File In Plain Text</li><br clear="all"/>
<li>View the <a href="textData.action">Text</a> File In Plain Text</li>
</ul>
</font>

</BODY>
</HTML>
-------------------------------------------------------------------------------------------------------------------------
testJSP.jsp
-----------------
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Plain Text Example</title>
</head>

<body bgcolor="lightblue">
<font size="6" face="modern">This is Plain Text Demo</font>
</body>
</html>
----------------------------------------------------------------------------------------------------------------------------
struts.xml
-----------------
<?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>

<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />

<package name="roseindia" extends="struts-default">

<action name="rawData" >

<result type="plainText">
<param name="location">/testJSP.jsp</param>
<param name="charSet">UTF-8</param>
</result>

</action>

<action name="textData" >

<result type="plainText">
<param name="location">/testText.txt</param>
<param name="charSet">UTF-8</param>
</result>

</action>

</package>

</struts>
----------------------------------------------------------------------------------------------------------------------
web.xml
-------------------
<?xml version="1.0" encoding="UTF-8"?>

<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                            http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        id="WebApp_ID" version="3.0">

<display-name>Struts 2</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.FilterDispatcher
</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
---------------------------------------------------------------------------------------------------------------------------
testText.txt
---------------------
Hi This is test raw file you are looking on the Browser ....................
----------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment