How to use servlets in struts2 - java

i have a struts2 web app and I want to use a servlet in my project,but struts2's filter does not allow to call servlets
I have looked into this solution, but unfortunately it didn't work out and the problem still stands.
Any ideas?
servlet code:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.print("morteza");
OutputStream o = response.getOutputStream();
InputStream is = new FileInputStream(new File("d:/Desert.jpg"));
byte[] buf = new byte[32 * 1024];
int nRead = 0;
while( (nRead=is.read(buf)) != -1 ) {
o.write(buf, 0, nRead);
}
o.flush();
o.close();
return;
}
struts.xml:
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<constant name="struts.action.excludePattern" value="Ser"/>
</struts>
web.xml:
<servlet>
<description></description>
<display-name>Ser</display-name>
<servlet-name>Ser</servlet-name>
<servlet-class>Ser</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ser</servlet-name>
<url-pattern>/Ser</url-pattern>
</servlet-mapping>
webpage:
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
fap
<img src="Ser" height="200" width="400"/>
</body>
</html>

you can use struts2 Stream Result for display the image
public class ImageAction extends ActionSupport{
public InputStream getImage() throws FileNotFoundException{
return new FileInputStream("f://test.jpg");
}
}
<action name="getImage" class="com.project.ImageAction">
<result name="success" type="stream">
<param name="contentType">image/jpeg</param>
<param name="inputName">Image</param>
<param name="contentDisposition">attachment;filename="image" </param>
<param name="bufferSize">1024</param>
</result>
</action>
if your project url like http://localhost:8080/project
<img src="http://localhost:8080/project/getImage" height="200" width="400"/>
or
<img src="getImage" height="200" width="400"/>

Related

Exception while registering custom interceptor in Struts2

I am new to Struts2 framework. i am working with custom interceptors to write logic for session management in my interceptor class which would be fired before accessing home page.here I have dummy custom interceptor only to check wether it executes or not but it throws exception while registering interceptor class. I dont know that is reason behind it.I just want it to work so that I could write my main logic than. Thanks dev.
Here is my code.
index.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<s:form action="login">
<s:textfield name="name" label="Username"/>
<s:submit value="Submit"/>
</s:form>
</body>
</html>
struts.xml
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
<interceptors>
<interceptor name="MyInterceptor" class="MyActions.MyInterceptor"/>
<interceptor-stack name="mystack">
<interceptor-ref name="MyInterceptor"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<action name="default">
<result>index.jsp</result>
</action>
<action name="login" class="MyActions.Login">
<interceptor-ref name="mystack"/>
<result name="SUCCESS">success.jsp</result>
</action>
</package>
</struts>
MyInterceptor.java
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
public class MyInterceptor implements Interceptor {
#Override
public String intercept(ActionInvocation invoke) throws Exception
{
System.out.println("Preprocessing.........");
String ret=invoke.invoke();
System.out.println("Post processing.........");
return ret;
}
#Override
public void destroy() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
#Override
public void init() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
Login.java
import com.opensymphony.xwork2.ActionSupport;
public class Login extends ActionSupport{
String name;
public String execute()
{
return "SUCCESS";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
success.jsp
<%#taglib prefix="s" uri="/struts-tags" %>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>
Hellow, <s:property value="name"/>
</h1>
</body>
</html>

The requested resource is not available in struts2 File upload

I am new to Struts2 and am developing a web application with file upload option. Everything has been configured but when i run the module HTTP Status 404 error: The requested resource is not available. (Link: http://localhost:8080/File_Upload/index.jsp). please find below my config,
index.jsp
<%# 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=UTF-8">
<title>File Upload</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.11.3.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/ajaxfileupload.js"></script>
<script type="text/javascript">
function ajaxFileUpload()
{
$("#loading")
.ajaxStart(function(){
$(this).show();
})//
.ajaxComplete(function(){
$(this).hide();
});//
$.ajaxFileUpload
(
{
url:'fileUploadAction.action',//
secureuri:false,//false
fileElementId:'myFile',//id <input type="file" id="file" name="file" />
dataType: 'json',// json
success: function (data, status) //
{
//alert(data.message);//jsonmessage,messagestruts2
$("#file_name").attr("value",data.myFile);
$("#file_path").attr("value",data.myFileFileName);
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
alert(data.error);
}else
{
alert(data.myFile);
}
}
},
error: function (data, status, e)//
{
alert(e);
}
}
)
return false;
}
</script>
</head>
<body>
<form action="upload" method="post" enctype="multipart/form-data">
<label for="myFile">Upload your file</label>
<input type="file" name="myFile" id="myFile"/>
<input type="button" value="" onclick="return ajaxFileUpload();">
<input type="hidden" name="file_name[]" id="file_name[]" value=""/>
<input type="hidden" name="file_path[]" id="file_path[]" value=""/>
<input type="submit"/>
</form>
<div id="loading"><span style="position: fixed;left: 50%;top: 50%; transform: translate(-50%, -50%); color:#f3cbbb ">
<img src="<%=request.getContextPath()%>/images/ajax-loader.gif" alt="loading" width="200" height="200" style="padding-left:85px">
<br /><br />
<span style=" font-weight: 700; font-size: 18px">Please wait,File is being uploaded
</span></span>
</div>
</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>
<package name="default" extends="struts-default">
<action name="fileUploadAction" class="com.tutorialspoint.struts2.MultipleFileUploadAction">
<result type="json" name="success">
<param name="contentType">text/html</param>
</result>
<result type="json" name="error">
<param name="contentType">text/html</param>
</result>
</action>
</package>
</struts>
Action.class:
package com.tutorialspoint.struts2;
import java.io.File;
import org.apache.commons.io.FileUtils;
import java.io.IOException;
import com.opensymphony.xwork2.ActionSupport;
public class MultipleFileUploadAction extends ActionSupport {
private File[] myFile;
private String[] myFileContentType;
private String[] myFileFileName;
private String destPath;
public String execute()
{
/* Copy file to a safe location */
destPath = "E:/kalidass/Upload/";
try{
for(int i=0;i<myFile.length;i++)
{
System.out.println("Src File name: " + myFile[i]);
System.out.println("Dst File name: " + myFileFileName[i]);
File destFile = new File(destPath, myFileFileName[i]);
FileUtils.copyFile(myFile[i], destFile);
}
}catch(IOException e){
e.printStackTrace();
return "error";
}
return "success";
}
public File[] getMyFile() {
return myFile;
}
public void setMyFile(File[] myFile) {
this.myFile = myFile;
}
public String[] getMyFileContentType() {
return myFileContentType;
}
public void setMyFileContentType(String[] myFileContentType) {
this.myFileContentType = myFileContentType;
}
public String[] getMyFileFileName() {
return myFileFileName;
}
public void setMyFileFileName(String[] myFileFileName) {
this.myFileFileName = myFileFileName;
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<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>
jar files:
Jar files
You have to add in your struts.xml this action inside your default package
<action name="index">
<result>/index.jsp</result>
</action>
In this way when you'll try to open http://localhost/myapp/index it will return the index.jsp

Display data from database with the property tag in Struts 2

When I want to display data from database using Struts 2 tags:
I have a problem in my JSP, it doesn't show anything. Although in Console I have the result
My Action class:
public class ObjectifAction extends ActionSupport implements ModelDriven<Objectif> {
/**
*
*/
private static final long serialVersionUID = 1L;
Objectif objectif = new Objectif();
List<Objectif> objectifs = new ArrayList<Objectif>();
ObjectifDAO objdao= new ObjectifDAO();
//objdao.countTotal();
public String afficher()
{
int i=0,taille;
objectifs = objdao.afficher();
taille=objdao.countTotal();
for(i=0;i<taille;i++){
System.out.println(objectifs.get(i).getDescription());
}
return "success";
}
public Objectif getObjectif() {
return objectif;
}
public void setObjectif(Objectif objectif) {
this.objectif = objectif;
}
public List<Objectif> getObjectifs() {
return objectifs;
}
public void setObjectifs(List<Objectif> objectifs) {
this.objectifs = objectifs;
}
public ObjectifDAO getObjdao() {
return objdao;
}
public void setObjdao(ObjectifDAO objdao) {
this.objdao = objdao;
}
#Override
public Objectif getModel() {
// TODO Auto-generated method stub
return objectif;
}
}
My 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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table>
<tr>
<td>id</td>
</tr>
<s:iterator value="objectifs" var="o">
<tr>
<td><s:property value="#o.id_objectif_metier"/></td>
</tr>
</s:iterator>
</table>
</body>
</html>
It doesn't display anything, please help!
This is my struts.xml file:
I think there is a mistake in the JSP page. It only shows the name of the column without data
<?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" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<!-- <constant name="struts.action.extension" value="xhtml,,xml,json,action"/> -->
<package name="rest" extends="rest-default" namespace="/rest">
</package>
<package name="default" extends="struts-default, json-default"
namespace="/">
<interceptors>
<interceptor class="ma.interceptors.LoginInterceptor"
name="loginInterceptor">
</interceptor>
<interceptor-stack name="loginStack">
<interceptor-ref name="loginInterceptor" />
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">ERROR</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<global-results>
<result name="login">index.jsp</result>
<result name="error">errors/error.jsp</result>
</global-results>
<action name="Connect" class="ma.actions.UtilisateurAction" method="Connect">
<result name="ADMIN" type="redirect">admin</result>
<result name="input" type="redirect">index.jsp</result>
</action>
<action name="admin">
<interceptor-ref name="loginStack" />
<result>/WEB-INF/admin/index.jsp</result>
</action>
<action name="listerObjectif" class="ma.actions.ObjectifAction" method="afficher">
<interceptor-ref name="loginStack" />
<result name="success" type="redirect">objectif</result>
</action>
<action name="objectif">
<interceptor-ref name="loginStack" />
<result>/WEB-INF/admin/objectif/objectif.jsp</result>
</action>
</package>
I don't think there is a mistake here?
The Struts is used to execute an action then return a JSP with the result. But redirect result type is used if you want to redirect to another URL. Doing this you loose everything used in JSP to populate data in your controls. Change
<action name="listerObjectif" class="ma.actions.ObjectifAction" method="afficher">
<interceptor-ref name="loginStack" />
<result>/WEB-INF/admin/objectif/objectif.jsp</result>
</action>

Unable to execute Struts 2 program with ModelDriven interceptor

I am new to Struts 2 framework. I have made a program for understanding modelDriven interceptor. But I am unable to execute it. Following are the list of files and in the end there is a output (error).
index.jsp:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib uri="/struts-tags" prefix="s"%>
<!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>
<%-- <jsp:useBean id="ent" class="pack.Entity" scope="session" /> --%>
<s:form method="get" action="go">
<s:textfield name="t1" label="Name"></s:textfield>
<s:password name="p1" label="Password"></s:password>
<s:submit value="accept"></s:submit>
</s:form>
</body>
</html>
Entity.java:
package actions_pack;
public class Entity {
private String t1;
private String p1;
public String getP1() {
return p1;
}
public void setP1(String p1) {
this.p1 = p1;
}
public Entity() {
super();
// TODO Auto-generated constructor stub
}
public String getT1() {
return t1;
}
public void setT1(String t1) {
this.t1 = t1;
}
}
GoAction.java:
package actions_pack;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor;
import com.opensymphony.xwork2.util.ValueStack;
public class GoAction implements ModelDriven<Entity> {
private Entity en;
public Entity getEn() {
return en;
}
public void setEn(Entity en) {
this.en = en;
}
public String execute(){
System.out.println("inside action");
if(en.getT1().equalsIgnoreCase("nitin")){
return "success";
}
else{
return "failure";
}
}
#Override
public Entity getModel() {
System.out.println("inside model driven....");
en=new Entity();
return en;
}
}
struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="dd">
<result-types>
<result-type name="dispatcher"
class="org.apache.struts2.dispatcher.ServletDispatcherResult"
default="true" />
</result-types>
<interceptors>
<interceptor name="modelDriven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>
<interceptor-stack name="myStack">
<interceptor-ref name="modelDriven"></interceptor-ref>
</interceptor-stack>
</interceptors>
<action name="go" class="actions_pack.GoAction">
<interceptor-ref name="myStack"></interceptor-ref>
<result name="success" type="dispatcher" >/one/welcome.jsp</result>
<result name="failure" type="dispatcher">/one/error.jsp</result>
</action>
</package>
</struts>
welcome.jsp:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib uri="/struts-tags" prefix="s" %>
<!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>
Welcome, <s:property value="t1"/>
</body>
</html>
web-page output(500 error):
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
actions_pack.GoAction.execute(GoAction.java:24)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.34 logs.
Apache Tomcat/7.0.34
In struts.xml file I don't want to use/extend struts-default package. Although, when I include params interceptor entry along with modelDriven interceptor in struts.xml, problem solves. What is the reason behind this. Can any one guide me?
You have a property in the action class that needs initialize prior to the action execution. You can do it in many ways.
The way you have chosen relies on modelDriven interceptor which is running before your action is executed. It invokes getModel() to push it on top of the valueStack. So, your entity property is being initialized. If you remove this interceptor you will get NullPointerException when the action is executed.
If your Entity is a simple POJO that you can instantiate yourself then simply do it inline instead of in getModel().
private Entity en = new Entity();
#Override
public Entity getModel() {
System.out.println("inside model driven....");
return en;
}
Next part is about params interceptor. It uses OGNL to populate a top object that is a model if you have used modelDriven interceptor prior params interceptor.
Living it along with your action allows to initialize some properties you reference in the execute().
For example t1 should be initialized.

Ajax with struts

I have a problem using ajax with struts
I want to load dependent dropdown list using ajax. I am using struts2.
Below is the code for the jsp.
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%# taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Enter Product</title>
<script type="text/javascript">
var request;
function findindex1()
{
var temp=document.getElementById("country").value;
if(window.ActiveXObject){ request = new ActiveXObject("Microsoft.XMLHTTP"); }
else if(window.XMLHttpRequest){ request = new XMLHttpRequest(); } request.onreadystatechange = showResult;
request.open("POST",'temp.action?index='+temp,true);
request.send(null);
}
function showResult(){
if(request.readyState == 4){
alert(request.responseText+"1");
document.getElementById("text").innerHTML=request.responseText; //Just to test
var val=<%=request.getParameter("index") %> -
/* document.getElementById("city").flush(); */
}
alert(request.responseText+"1");
}
function change(){
var temp=document.getElementById("country").value;
location.href='loadProduct.action';
}
</script>
</head>
<body onload="fill()">
<s:form method="post" action="product.action" name="product" theme="simple">
<table id="table">
<tr><td>Country</td><td><s:select id="country" name="country.countryId" list="countryList" listKey="countryId"
listValue="name" onchange="findindex1()" ></s:select></td></tr>
<tr>
<td>City</td>
<td><s:select id="city" name="city.id" list="cities" listKey="id"
listValue="name" headerKey="city.id" ></s:select></td>
</tr>
<tr>
<td>Product Desc</td>
<td><s:textfield name="product.description"></s:textfield></td>
</tr>
<tr>
<td>Product Name</td>
<td><s:textfield name="product.name"></s:textfield></td>
</tr>
<tr>
<td><s:submit id="search" name="submit" value="Search"></s:submit></td>
<td><s:submit name="submit" value="Create"></s:submit>
</td>
</tr>
<tr>
<td></td>
<td><s:label id="text" name="text">Text to change</s:label>
</td>
</tr>
</table>
</s:form>
</body>
</html>
I have checked the code and it sets the value of the List cities in the action class on changing the value of the country dropdown in the jsp. But i am unable to reflect the changes in the jsp .
The action class function is :
public String temp()
{
String[] id=(String[])getParameters().get("index");
index=Integer.parseInt(id[0]);
cities=(ArrayList<City>)productCreateService.selectCities(Integer.parseInt(id[0]));
for(Iterator<Country> i=countryList.iterator();i.hasNext();)
{
Country c = i.next();
if(c.getCountryId()==Integer.parseInt(id[0]))
{
Country c1= countryList.get(0);
country=c;
break;
}
}
String out="";
for(Iterator<City> i=cities.iterator();i.hasNext();)
{
}
inputStream = new StringBufferInputStream("Hello World! This is a text string response from a Struts 2 Action.");
return SUCCESS;
}
All the varibles have getter setters . I know the code is messed up . Initially i testes it for cities tag. When that didnt work i tried testing on a simple tag (here id="text") . But even that didnt work .
The model, Services and DAO(though not here) are all correct.
The struts.xml file is as follows .
<!-- Some or all of these can be flipped to true for debugging -->
<constant name="struts.i18n.reload" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="struts.configuration.xml.reload" value="false" />
<constant name="struts.custom.i18n.resources" value="global" />
<constant name="struts.action.extension" value="action" />
<constant name="struts.serve.static" value="true" />
<constant name="struts.serve.static.browserCache" value="false" />
<constant name="actionPackages" value="com.oxxo.pilot.web.action" />
<package name="default" extends="struts-default" namespace = "/">
<global-results>
<result name="custom_error">/jsp/exception.jsp</result>
<result name="input">/jsp/fail.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception"
result="custom_error" />
<action name="temp" class="ProductAction" method="temp">
<result type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
</action>
</package>
Could somebody please tell me what am i doing wrong. If you need any part of the code please let me know . Thanks .

Categories