I just tested the upload actions in the Struts 2 showcase and the findings are 
the same: the file upload is broken in Weblogic v12.1.1. Who will fix that? 
Thanks, Peter


-----Ursprüngliche Nachricht-----
Von: peter.kel...@meteoswiss.ch [mailto:peter.kel...@meteoswiss.ch] 
Gesendet: Dienstag, 31. Januar 2012 15:14
An: user@struts.apache.org
Betreff: File upload from JSP with "multipart/form-data" does not work on 
Weblogic v12c

Dear list

File upload from JSP with "multipart/form-data" does not work on Weblogic v12c 
which supports Java Servlet specification v3.0. The same code worked as 
expected for Weblogic v10.3.X which supports Java Servlet specification v2.4. 
The same code does NOT work with Struts v2.1.8 on Weblogic v12c.

Debugging the application with Weblogic running in Eclipse I found out, that 
ALL parameters given in the JSP form (data, contextTx) are simply ignored. The 
"method" attribute in the <s:submit> tag is also ignored and therefore Struts 
always invokes the execute() method of the Struts action.

Please find the setup below.

Is this is a bug? Or is something wrong with the setup?

Thanks, Peter

web.xml:

<?xml version='1.0' encoding='ISO-8859-1'?> <web-app 
xmlns="http://java.sun.com/xml/ns/j2ee"; 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
        version="2.4">

        <description>Datadispatcher Console</description>
        <display-name>Datadispatcher Web</display-name>

        <context-param>
                <description>Tiles configuration file</description>
                
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
                <param-value>/WEB-INF/tiles.xml</param-value>
        </context-param>

        <listener>
            
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
        </listener>

        <servlet>
            <servlet-name>tiles</servlet-name>
            
<servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
            <load-on-startup>2</load-on-startup>
        </servlet>

        <servlet>
            <servlet-name>tiles-dispatch</servlet-name>
            
<servlet-class>org.apache.tiles.web.util.TilesDispatchServlet</servlet-class>
        </servlet>

        <servlet-mapping>
            <servlet-name>tiles-dispatch</servlet-name>
            <url-pattern>*.tiles</url-pattern>
        </servlet-mapping>

        <filter>
            <filter-name>struts</filter-name>
            
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
        </filter>
        
        <filter-mapping>
            <filter-name>struts</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>

</web-app>

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>
    <constant name="struts.devMode" value="false" />
    <constant name="struts.multipart.saveDir" value="/tmp" />
    <constant name="struts.i18n.encoding" value="ISO-8859-1" />

    <package name="dd-default" extends="struts-default">
        <result-types>
            <result-type name="tiles" 
class="org.apache.struts2.views.tiles.TilesResult"/>
        </result-types>
        <default-interceptor-ref name="defaultStack"/>             
        <action name="Upload" 
class="ch.meteoswiss.datadispatcher.console.UploadAction">
            <result type="tiles">upload.page</result>
            <result name="input" type="tiles">upload.page</result>
        </action>
    </package>
</struts>

JSP:

<%@ taglib prefix="s" uri="/struts-tags" %>

<h2>Upload</h2>
<s:form method="post" enctype="multipart/form-data" action="Upload" 
theme="simple"> <table>
  <tr><td>Content Id</td><td><s:textfield name="contentTx" size="20"/></td></tr>
  <tr valign="middle"><td>Import File</td><td><s:file name="data" 
size="60"/></td></tr> </table> <br/> <s:submit value="Upload" method="upload"/> 
</s:form>

Java Action:

package ch.meteoswiss.datadispatcher.console;

public class UploadAction extends ActionSupport {

    private static final Logger logger = Logger.getLogger(UploadAction.class);

    private String contentTx;

    private File data;
    private String dataContentType;
    private String dataFileName;

    public String execute() {
        logger.info("**** execute ****");
        return super.execute();
    }
   
    public String upload() throws Exception {
        logger.info("**** upload ****");
        logger.info("data = "+data);
        logger.info("contentTx = "+contentTx);
        return SUCCESS;
    }
    public void setContentTx(String contentTx) {
        this.contentTx = contentTx;
    }
    public String getContentTx() {
        return contentTx;
    }
    public void setData(File data) {
        this.data = data;
    }
    public File getData() {
        return data;
    }
    public void setDataContentType(String dataContentType) {
        this.dataContentType = dataContentType;
    }
    public String getDataContentType() {
        return dataContentType;
    }
    public void setDataFileName(String dataFileName) {
        this.dataFileName = dataFileName;
    }
    public String getDataFileName() {
        return dataFileName;
    }
}
  



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to