Uploading file problem in JSF using myfaces-extensions.jar.

Dear All,
I'm new to JSF and trying to upload files using myfaces-extensions-1.0.9.jar and commons-fileupload-1.2.1.jar.
I have upload.jsp and result.jsp and a bean named MyBean.java. after press the submit button it should navigate to result.jsp and shows some info.
My problem is that it successfully run but when submit its not working and remain same page.
upload.jsp:
{<%@page contentType="text/html" pageEncoding="windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<f:view>
<h:form id="MyForm" enctype="multipart/form-data" >
<h:messages globalOnly="true" styleClass="message"/>
<h:panelGrid columns="3" border="0" cellspacing="5">
<h:outputLabel for="myFileId" value="File: "/>
<x:inputFileUpload id="myFileId"
value="#{myBean.myFile}"
storage="file"
required="true"/>
<h:message for="myFileId"/>
<h:outputLabel for="myParamId" value="Param: "/>
<h:selectOneMenu id="myParamId"
value="#{myBean.myParam}"
required="true">
<f:selectItem itemLabel="" itemValue=""/>
<f:selectItem itemLabel="MD5" itemValue="MD5"/>
<f:selectItem itemLabel="SHA-1" itemValue="SHA-1"/>
<f:selectItem itemLabel="SHA-256" itemValue="SHA-256"/>
<f:selectItem itemLabel="SHA-384" itemValue="SHA-384"/>
<f:selectItem itemLabel="SHA-512" itemValue="SHA-512"/>
</h:selectOneMenu>
<h:message for="myParamId"/>
<h:outputText value=" "/>
<h:commandButton id = "test" value="Submit"
action="#{myBean.processMyFile}"/>
<h:outputText value=" "/>
</h:panelGrid>
</h:form>
</f:view>
faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<!-- =========== FULL CONFIGURATION FILE ================================== -->
<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<managed-bean>
<managed-bean-name>myBean</managed-bean-name>
<managed-bean-class>
com.devsphere.articles.jsfupload.MyBean
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/upload.jsp</from-view-id>
<navigation-case>
<from-outcome>OK</from-outcome>
<to-view-id>/result.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Can anybody there for help me whats the problem. I'm using netbeans 6.1 with bundled tomcat 6.0 and no error is shown.

Hey All,
I've got my solve. Now Its working.

Similar Messages

  • Down-/Upload files via Web Services using a NON-SAP system!?

    Hello,
    is it possible to down-/upload files via web services using a NON-SAP system!?
    Regards,
    Jens

    Hi Jens,
    I am not sure about your requirement here. What i could understand is that you want to check whether service could handle file processing?
    1) Uploading file - You can build a Webservice which has import/export parameters as the file structures and implement the proxy class in such a way that the passed data is written to application server.
    2) Downloading file - Same as uploading file, but the proxy class would have the code to extract data from the application server and pass them as output parameter.
    Functionality of Non SAP system: The system which calls these services should be able to convert the output of proxy data into file in case of downloading the file and it should be able to convert the file data into export parameters in case of uploading file.
    Hope this helps.
    Regards,
    Prasanna

  • Uploading files to KM repository using Webdynpro APIs

    Hi All,
    I was reading the following blog /people/rohit.radhakrishnan/blog/2005/05/27/uploading-files-to-km-repository-using-webdynpro-apis and I was trying to upload a document from a URL for example http:/ntek.com.mx/wp-content/uploads/2008/12/sap_logo1.gif
    So far I am getting the following error:
    http:/ntek.com.mx/wp-content/uploads/2008/12/sap_logo1.gif (No such file or directory (errno:2))
    Any Ideas?
    Regards,
    Orlando Covault

    Hi Jay,
    So far I think I followed all the intructions given in the links you provide. This is the snipped code
    IWDMessageManager manager = wdComponentAPI.getMessageManager();
              try {
                   String path = "/documents";
                   IResourceContext resourceContext = buildResourceContext();
                   //       get a resource factory
                   IResourceFactory resourceFactory = ResourceFactory.getInstance();
                   //       Get a RID from the current path to display the according content
                   RID pathRID = RID.getRID(path);
                   //       Get a Iresource object to work on          
                   ICollection folder =
                        (ICollection) resourceFactory.getResource(
                             pathRID,
                             resourceContext);
                   String templateUrl =
                        WDURLGenerator.getResourcePath(
                             wdComponentAPI.getDeployableObjectPart(),
                             "PositionModPDFView_InteractiveForm.xdp");
                   File file = new File(templateUrl);
                   FileInputStream template = new FileInputStream(file);
                   manager.reportWarning(template.toString());
                   if (template != null) {
                        template.read();
                        Content content = new Content(template, "byte", -1L);
                        manager.reportWarning(content.getContentType());
                        IResource newResource =
                             folder.createResource("sap_logo1.gif", null, content);
                        template.close();
                   }else{
                        manager.reportException("Documento Vacio",false);
              } catch (ResourceException e) {
                   // TODO Auto-generated catch block
                   manager.reportException(e.getLocalizedMessage(), false);
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   manager.reportException(e.getLocalizedMessage(), false);
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   manager.reportException(e.getLocalizedMessage(), false);
              } catch (ContentException e) {
                   // TODO Auto-generated catch block
                   manager.reportException(e.getLocalizedMessage(), false);
              } catch (WDAliasResolvingException e) {
                   // TODO Auto-generated catch block
                   manager.reportException(e.getLocalizedMessage(), false);
    But I am still getting the same error:  http://ntek.com.mx/wp-content/uploads/2008/12/sap_logo1.gif(No such file or directory (errno:2)) . Any Idea of what could be wriong?
    Regards,
    Orlando Covault

  • Again JSF upload file problem.

    I am using My Faces to upload files. There is a way to limit the size of uploaded files.
    <filter>
            <filter-name>ExtensionsFilter</filter-name>
            <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
            <init-param>
                <param-name>uploadMaxFileSize</param-name>
                <param-value>7m</param-value>
            </init-param>
            <init-param>
                <param-name>uploadThresholdSize</param-name>
                <param-value>100k</param-value>
            </init-param>
        </filter>When I try to upload bigger than 7 MB file, I receive the following log.
    2007-05-23 13:58:20,796 [http-8080-Processor24] INFO org.apache.myfaces.component.html.util.MultipartRequestWrapper - user tried to upload a file that exceeded file-size limitations.
    org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because it's size exceeds allowed range
         at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:317)
         at org.apache.myfaces.component.html.util.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:70)
         at org.apache.myfaces.component.html.util.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:151)
         at org.apache.myfaces.context.servlet.RequestParameterMap.getAttribute(RequestParameterMap.java:39)
         at org.apache.myfaces.context.servlet.AbstractAttributeMap.get(AbstractAttributeMap.java:87)
         at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getTreeStructureToRestore(HtmlResponseStateManager.java:181)
         at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreTreeStructure(JspStateManagerImpl.java:142)
         at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:181)
         at org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
         at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:113)
         at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)
    By now, OK. Here comes the problem: The behavior of application is correct after this, which I can see from the rest of my log, BUT my browser continue to say that the request is being processed and that the page continues to load, which is not true, and I can not find where is the reason.
    Do you have any idea?

    Check this code if it is useful
    REPORT  ZSRK_046                                .
    DATA : FIR_FILE(512) VALUE '
    iltlvp01.t.st.corp\DE_Development\EP 6\Port\dept\Program Office\TEST.json'.
    TYPES: BEGIN OF TP_DATA_TAB,
           TEXT(512),
           END OF TP_DATA_TAB.
    DATA : DATA_TAB TYPE STANDARD TABLE OF TP_DATA_TAB,
           WA_DATA_TAB LIKE LINE OF DATA_TAB .
    DATA : WA(512).
    OPEN DATASET FIR_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF SY-SUBRC EQ 0.
      DO.
        READ DATASET FIR_FILE INTO WA.
        IF SY-SUBRC NE 0.
          EXIT.
        ENDIF.
        WA_DATA_TAB-TEXT = WA.
        APPEND WA_DATA_TAB TO DATA_TAB.
        CLEAR : WA_DATA_TAB, WA.
      ENDDO.
    ENDIF.
    LOOP AT DATA_TAB INTO WA_DATA_TAB.
      WRITE : / WA_DATA_TAB-TEXT.
    ENDLOOP.

  • Visual Web JSF Portlet Upload file Problem in Websynergy

    Hello,
    I am using Websynergy milestone 3 release. I have tried to build AS A PORTLET the sample code, "Uploading Files in NetBeans Visual Web JSF Applications" (http://www.netbeans.org/kb/60/web/intro.html) using netbeans 6.5. The solution deploys successfully but unfortunately, the file Upload control does not work in the websynergy portlet environment. No file seems to be uploaded. The same code works very well in non-portlet environment. Is there a work-around for the Portlet environment?
    Looking forward to some help!
    Pius

    Hello,
    I am using Websynergy milestone 3 release. I have tried to build AS A PORTLET the sample code, "Uploading Files in NetBeans Visual Web JSF Applications" (http://www.netbeans.org/kb/60/web/intro.html) using netbeans 6.5. The solution deploys successfully but unfortunately, the file Upload control does not work in the websynergy portlet environment. No file seems to be uploaded. The same code works very well in non-portlet environment. Is there a work-around for the Portlet environment?
    Looking forward to some help!
    Pius

  • Upload file component in JSF 1.2

    Hi,
    I am developing an application with JSF 1.2 . I am using a custom component made with Apache Commons FileUpload 1.2.1 API which purpose is to upload files. This component work only if the form data is encoded with the “multipart/form-data” encoding instead of the usual “application x-www-form-urlencoded” encoding. From what I know JSF 1.2 doesn't handle this type of encoding. To overcome this issue, I install a servlet filter that intercepts a file upload and turns uploaded files into request attributes. The problem is that when the form data is encoded with the “multipart/form-data” encoding no characters are encoded. I have other JSF components in this form and in them I put different international characters which are lost when the form is submit because they are not encoded.
    Can somebody help me with this issue ?

    I have a filter
    import java.io.File;
    import java.io.IOException;
    import java.util.Collections;
    import java.util.Enumeration;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletRequestWrapper;
    import org.apache.commons.fileupload.FileItem;
    import org.apache.commons.fileupload.FileUploadException;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    public class UploadFilter implements Filter {
    private int sizeThreshold = -1;
    private String repositoryPath;
    public void init(FilterConfig config) throws ServletException {
    repositoryPath = config.getInitParameter(
    "com.corejsf.UploadFilter.repositoryPath");
    try {
    String paramValue = config.getInitParameter(
    "com.corejsf.UploadFilter.sizeThreshold");
    if (paramValue != null)
    sizeThreshold = Integer.parseInt(paramValue);
    catch (NumberFormatException ex) {
    ServletException servletEx = new ServletException();
    servletEx.initCause(ex);
    throw servletEx;
    public void destroy() {
    public void doFilter(ServletRequest request,
    ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
    if (!(request instanceof HttpServletRequest)) {
    chain.doFilter(request, response);
    return;
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    boolean isMultipartContent
    = ServletFileUpload.isMultipartContent(httpRequest);
    if (!isMultipartContent) {
    chain.doFilter(request, response);
    return;
    DiskFileItemFactory factory = new DiskFileItemFactory();
    if (sizeThreshold >= 0)
    factory.setSizeThreshold(sizeThreshold);
    if (repositoryPath != null)
    factory.setRepository(new File(repositoryPath));
    ServletFileUpload upload = new ServletFileUpload(factory);
    try {
    List<FileItem> items = (List<FileItem>) upload.parseRequest(httpRequest);
    final Map<String, String[]> map = new HashMap<String, String[]>();
    for (FileItem item : items) {
    String str = item.getString();
    if (item.isFormField())
    map.put(item.getFieldName(), new String[] { str });
    else
    httpRequest.setAttribute(item.getFieldName(), item);
    chain.doFilter(new
    HttpServletRequestWrapper(httpRequest) {
    public Map<String, String[]> getParameterMap() {
    return map;
    // busywork follows ... should have been part of the wrapper
    public String[] getParameterValues(String name) {
    Map<String, String[]> map = getParameterMap();
    return (String[]) map.get(name);
    public String getParameter(String name) {
    String[] params = getParameterValues(name);
    if (params == null) return null;
    return params[0];
    public Enumeration<String> getParameterNames() {
    Map<String, String[]> map = getParameterMap();
    return Collections.enumeration(map.keySet());
    }, response);
    } catch (FileUploadException ex) {
    ServletException servletEx = new ServletException();
    servletEx.initCause(ex);
    throw servletEx;
    a render
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.UnsupportedEncodingException;
    import javax.el.ValueExpression;
    import javax.faces.FacesException;
    import javax.faces.component.EditableValueHolder;
    import javax.faces.component.UIComponent;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    import javax.faces.render.Renderer;
    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.commons.fileupload.FileItem;
    public class UploadRenderer extends Renderer {
    public void encodeBegin(FacesContext context, UIComponent component)
    throws IOException {
    if (!component.isRendered()) return;
    ResponseWriter writer = context.getResponseWriter();
    String clientId = component.getClientId(context);
    writer.startElement("input", component);
    writer.writeAttribute("type", "file", "type");
    writer.writeAttribute("name", clientId, "clientId");
    writer.endElement("input");
    writer.flush();
    public void decode(FacesContext context, UIComponent component) {
    ExternalContext external = context.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) external.getRequest();
    String clientId = component.getClientId(context);
    FileItem item = (FileItem) request.getAttribute(clientId);
    Object newValue;
    ValueExpression valueExpr = component.getValueExpression("value");
    if (valueExpr != null) {
    Class valueType = valueExpr.getType(context.getELContext());
    if (valueType == byte[].class) {
    newValue = item.get();
    else if (valueType == InputStream.class) {
    try {
    newValue = item.getInputStream();
    } catch (IOException ex) {
    throw new FacesException(ex);
    else {
    String encoding = request.getCharacterEncoding();
    if (encoding != null)
    try {
    newValue = item.getString(encoding);
    } catch (UnsupportedEncodingException ex) {
    newValue = item.getString();
    else
    newValue = item.getString();
    ((EditableValueHolder) component).setSubmittedValue(newValue);
    ((EditableValueHolder) component).setValid(true);
    Object target = component.getAttributes().get("target");
    if (target != null) {
    File file;
    if (target instanceof File)
    file = (File) target;
    else {
    ServletContext servletContext
    = (ServletContext) external.getContext();
    String realPath = servletContext.getRealPath(target.toString());
    file = new File(realPath);
    try { // ugh--write is declared with "throws Exception"
    item.write(file);
    } catch (Exception ex) {
    throw new FacesException(ex);
    and a simple tag handler it is nothing special.
    This code is taken from an example in the book Core JavaServer Faces Second Edition 2007

  • Urgent !!!!!!!!!!!!!Uploading File problem

    Hi I stucked on a problem...... I want to upload file from html page....On this page I want only a upload button so that when I click on this button file will upload from my client m/c to server m/c.... I have code n all but browse button on html page....now I want to remove this browse button n want to give the file path somewhere in the code itself........so that on html page there will only the uplod button and by click on this button file will upload from client to server.......server path already there in code.....Please do the needful  Abhishek  I m putting the code here:-  FileUpload.java  /* upload-FileUpload.java  NOTE: This file is a generated file. Do not modify it by hand! */  package upload;   //custom imports for FileUpload //add your custom import statements here  import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import com.oreilly.servlet.MultipartRequest; import java.util.*;   public class FileUpload extends javax.servlet.http.HttpServlet { protected boolean create() throws java.lang.Exception {  return true; }   public FileUpload() { // Constructor.  } private void unhandledEvent( String listenerName, String methodName, java.lang.Object event ) {  } /** * destroy Method */  public void destroy() { super.destroy(); // TODO: implement } /** * doGet Method */  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("abhishek"); response.setContentType( "text/html" );  PrintWriter out = response.getWriter();  out.println("<HTML>");  out.println("<HEAD><TITLE>FileUpload</TITLE></HEAD>");  out.println("<BODY>");  out.println("<H1>FileUpload</H1>");  out.println("Hello World!");  out.println(" Default Implementation From PowerJ  ");  out.println("</BODY></HTML>");   // TODO: implement } /** * doPost Method */  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {   PrintWriter out = response.getWriter();  try{ response.setContentType("text/html"); out.println("<HTML>"); out.println("<head><Title>Decoded Uploaded File</title><head>");  out.println("<body>"); out.println("<H1>UploadFile</h1>");  // path must be absolute to upload dir // This is the decoder class that extracts the parameters and transfer file // request argument = Http input stream // c:\\temp\\upload = directory to save file // 15*1024*1024 = 15mb max size file MultipartRequest multi = new MultipartRequest(request, "c:\\temp\\upload",15*1024*1024);   // Lists form parameters out.println("Params:"); Enumeration params = multi.getParameterNames(); out.println("<pre>");  while (params.hasMoreElements()) { String name = (String)params.nextElement(); String value = multi.getParameter(name); out.println(name + " = " + value); }  out.println("</pre>");   // Show details of uploaded file out.println("Files:"); Enumeration files = multi.getFileNames();  out.println("<pre>"); while (files.hasMoreElements()) { String name = (String)files.nextElement(); String filename = multi.getFilesystemName(name); String type = multi.getContentType(name); File f = multi.getFile(name); out.println("name: " + name); out.println("filename: " + filename); out.println("type: " + type); if (f != null) { out.println("f.toString(): " + f.toString()); out.println("f.getName(): " + f.getName()); out.println("f.exists(): " + f.exists()); out.println("f.length(): " + f.length()); out.println(); } out.println("</pre>"); }  }catch (Exception e){ out.println("<pre>"); e.printStackTrace(out); out.println("</pre>"); } out.println("</body></html>"); } /** * init Method */  public void init(ServletConfig config) throws ServletException { super.init(config); // TODO: implement } /**************************************** * data members ****************************************/   // add your data members here }  --------------------------------------------------------------------------------------------------  UploadFile.html  <html>  <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>File Upload using EAS</title> </head>  <body>  <form method="POST" enctype="multipart/form-data" action="upload/FileUpload">  <b>File Upload using EAS </b>    Select file to send: <input type="file" name="name" size="30">    Your Name: <input type="input" name="yourname" size="20">     <input type="submit" value="Send File" name="submit">   </form>  </body>  </html> ----------------------------------------------------------------------------------------------  You can download the oreilly files from :- (same code is also here)  http://www.sybase.com/detail?id=1011664

    I m putting the code again with code tags:-
    code is here
    FileUpload.java
    package upload;
    //custom imports for FileUpload
    //add your custom import statements here
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import com.oreilly.servlet.MultipartRequest;
    import java.util.*;
    public class FileUpload extends javax.servlet.http.HttpServlet
    protected boolean create() throws java.lang.Exception
    return true;
    public FileUpload()
    { // Constructor.
    private void unhandledEvent( String listenerName, String methodName, java.lang.Object event )
    * destroy Method
    public void destroy()
    super.destroy();
    // TODO: implement
    * doGet Method
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    System.out.println("abhishek");
    response.setContentType( "text/html" );
    PrintWriter out = response.getWriter();
    out.println("<HTML>");
    out.println("<HEAD><TITLE>FileUpload</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<H1>FileUpload</H1>");
    out.println("Hello World!");
    out.println("
    Default Implementation From PowerJ
    out.println("</BODY></HTML>");
    // TODO: implement
    * doPost Method
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    PrintWriter out = response.getWriter();
    try{
    response.setContentType("text/html");
    out.println("<HTML>");
    out.println("<head><Title>Decoded Uploaded File</title><head>");
    out.println("<body>");
    out.println("<H1>UploadFile</h1>");
    // path must be absolute to upload dir
    // This is the decoder class that extracts the parameters and transfer file
    // request argument = Http input stream
    // c:\\temp\\upload = directory to save file
    // 15*1024*1024 = 15mb max size file
    MultipartRequest multi = new MultipartRequest(request, "c:\\temp\\upload",15*1024*1024);
    // Lists form parameters
    out.println("Params:");
    Enumeration params = multi.getParameterNames();
    out.println("<pre>");
    while (params.hasMoreElements()) {
    String name = (String)params.nextElement();
    String value = multi.getParameter(name);
    out.println(name + " = " + value);
    out.println("</pre>");
    // Show details of uploaded file
    out.println("Files:");
    Enumeration files = multi.getFileNames();
    out.println("<pre>");
    while (files.hasMoreElements()) {
    String name = (String)files.nextElement();
    String filename = multi.getFilesystemName(name);
    String type = multi.getContentType(name);
    File f = multi.getFile(name);
    out.println("name: " + name);
    out.println("filename: " + filename);
    out.println("type: " + type);
    if (f != null) {
    out.println("f.toString(): " + f.toString());
    out.println("f.getName(): " + f.getName());
    out.println("f.exists(): " + f.exists());
    out.println("f.length(): " + f.length());
    out.println();
    out.println("</pre>");
    }catch (Exception e){
    out.println("<pre>");
    e.printStackTrace(out);
    out.println("</pre>");
    out.println("</body></html>");
    * init Method
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    // TODO: implement
    * data members
    // add your data members here
    }UploadFile.html
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>File Upload using EAS</title>
    </head>
    <body>
    <form method="POST" enctype="multipart/form-data" action="upload/FileUpload">
    <b>File Upload using EAS </b>
    Select file to send: <input type="file" name="name" size="30">
    Your Name: <input type="input" name="yourname" size="20">
    <input type="submit" value="Send File" name="submit">
    </form>
    </body>
    </html>[                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Upload file problems

    I have a jsp form which is used to upload file...following is the code..
    <form name='fileUploadFrm' METHOD="POST" ENCTYPE="multipart/form-data" action='/myServlet?prma=1&prmb=2' onSubmit="return validateForm(this);">
    <H2>Upload File <H2>
    <table class="tabledatadisplay" border='0' cellpadding='0' cellspacing='3'>
    <tr><td>File Name/ID:</td><td> <input name='fileName' type='text'></td></tr>
    <tr><td>File Description:</td><td><input name='fileDesc' type='text'></td></tr>
    <tr><td>File:</td><td> <input name='fileContent' type='file'></td></tr>
    <tr><td colspan='2'> </td></tr>
    <tr><td> </td><td><input name='attach' type='submit' value=' Upload File ' onClick="return confirm('Are you sure you want to upload the file.');"></td></tr>
    </table>
    </form>
    intially i used two hidden fields prma and prmb..it didn't work so I changed the action string to include both the hidden fields...
    Now I get null values when I use the following code in myServlet
    request.getParameter("fileName");
    request.getParameter("fileDesc");
    I do get the file, i mean from the file input element
    I am using multiparser etc..in myServlet, I could able to read the contents and save it to database, but I couldn't able ot retrieve the text field and hidden field values in myServlet
    strange...can't figure out wy it is so????
    someone pls help me with this...

    Hi I am also working on the same problem and my next task is to display the contents to the browser and give him an option to either only open the document or save it to hard disk. I am doing it through setting the response.setContentType(content-disposition, attachment, filename") but it does not display the contents, it shows the dialog box but not the contents. please help me if u can...i m sending u some helping code..
    PreparedStatement preparedStatement2 =
    conn.prepareStatement("SELECT content,filename FROM tab_file );
    ResultSet resultSet = preparedStatement2.executeQuery();
    while(resultSet.next())
    Blob blob = resultSet.getBlob(1);
    byte [] b = blob.getBytes(1, length );
    response.setHeader("Content-Disposition","attachment; filename=untitled.java");
    ServletOutputStream servletOut = response.getOutputStream();
    servletOut.write(buf);
    servletOut.close();
    thnx

  • How to upload files from a form using pl/sql ?

    Hi
    Is it possible to upload the physical files outside the database (under UNIX server)using pl/sql? I already know how to store the files inside the database(wwwdoc_documents$) but I didn't find any documentation about storing the physical files outside the database.
    I have in my form the following component:
    <input type="file" name="upload">
    and I want to let the user browse for the file on his/her disc that he want to use. What I want to do next is to save a copy of that file on our file-server, and then use it in my application. How do I do that in pl/sql?
    Any help will be appreciated.
    Sebas.

    Thanks for the suggestion. I like this approach as Java is more familiar to me than other languages.
    Our DBA is out of touch today, so I could not grant the javauserpriv to my database user. I tried to run the script anyway in the chance that my user had the privs, and it seemed to have hung. I am now combing Oracle's site for more documentation so I can write some tests to see if I can get a basic Java object working. Under what heading would I find this?
    ajt

  • MULTIPLE UPLOAD file problem

    Hello,
    I have a problem with multiple upload file tool.
    Because my server need, in order to upload files in its folders, to be logged only with ftp user (that is unique).
    Now, I need that when I upload a file its name will be stored on db table "file_name". But in order to put data in database i have tobe logged also with user that is allowed to access on mysql db.
    So I understand that I should nedd to types of authentication at the same time...
    I think it depends on my type of hosting that is windows, and there is not the possibility to change CHMOD, so the error when I try to upload a file is that the folder has not write permissions...
    Any suggestions?
    Thanks a lot
    ascaro231
    Italy

    Hi ascaro231,
    wow, that is one bag of problems on the remote side :-(
    to be logged only with ftp user
    although PHP itself provides native FTP functions
    (e.g. for uploading files and also changing folder & file permissions), ADDT´s file upload features don´t support this protocol
    and there is not the possibility to change CHMOD
    CHMOD *will* have to be supported by your host, because this is how ADDT changes folder & file permissions.
    Well, to me it seems that your host doesn´t provide some very basic and truly common-standard PHP settings -- and honestly, disabling the regular PHP file upload features is ridiculous.
    Any suggestions?
    go for a better host -- this is just inacceptable.
    Are you hosting with "Aruba" BTW ? They have both Windows and Linux hostings, and AFAIK it´s possible to switch the hosting type.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Upload file problem

    hi......
    i am using struts.....
    i want to upload a file from client to server......but i am using enctype="multipart/form-data" in my jsp........it prompt out a err message
    javax.servlet.ServletException: Servlet execution threw an exception
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:275)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at com.entertainment.system.EntertainmentFilter.doFilter(EntertainmentFilter.java:70)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)
    please help.....thank you

    at com.entertainment.system.EntertainmentFilter.doFilter(EntertainmentFilter.java:70)That is your own filter I'm assuming and line 70 of that filter is causing your exception. So check out that line to see what the offending code is.
    I'm guessing that line does something with a parameter you retrieved, which is most likely null. A multipart form requires an API that can parse a multipart request, you cannot get file uploads (or other multipart fields) using the HttpServletRequest. I suggest you try out Apache commons FileUpload.
    http://jakarta.apache.org/commons/fileupload/

  • Uploading files a landing server using webutil

    dear all,
    i have the current situation and i'm looking for solution.
    i'm using the webutil in order to upload files from the client side to a landing server, the situation here is :
    when i use the following code
    webutil_file_transfer.Client_To_AS_with_progress
    (clientFile => :upload.file_name
    ,serverFile => 'd:\temp\'||l_bare_filename
    ,progressTitle => 'Upload to Application Server in progress'
    ,progressSubTitle => 'Please wait'
    ,asynchronous => false
    ,callbackTrigger => null
    where d:\temp is alocal directory on the AS
    but if i change the server file to a drive mapping i'll have the following error
    WUT-132, my question here is it possible for the webutil to upload a file to another landing server other than AS?
    how can i do it without making a hidden share to the folder ?
    the other question if i have a firewall between the client and the AS, will it prevent the webutil uploading process ?

    i want to add another point, when we make hidden share to the map drive the uploading worked successfuly.
    what i need here is a way to access the map drive without making hidden share to the map drive?

  • Sending uploaded file to the approver using GP Process

    Hai all,
    i my project i need to send the resource files for approver ...
    in my application i have created three actions under one sequencial block ..i need to send the user uploaded files to the three approvers .....

    Hi Ravi,
    You can send email with attachment to multiple approver's using webdynpro api. Please check below link -
    http://wiki.sdn.sap.com/wiki/display/WDJava/Sendmailwithattachmentusingwebdynpro+API%27s
    Regards,
    Sen

  • Creative Cloud Files - problem with space used.

    Hello. Creative Cloud Files - it says I used 20 GB, but I only uploaded a few hundred MB and my sync folder has 16 GB. Thank you.

    Hi Lucian I sent you a private message.
    Thanks,
    - Dave B

  • Uploading files problem.

    I have got a confusion in uploading files from user machine.
    we use <input type='file' name='fileName'/> tag for that.
    now at server side how we get the file:
    request.getParameter('fileName'); ?
    if yes then:
    but getParameter function returns a string, and a file data (eg image file) can't represented as a string.
    if no then:
    what function of request object we should use for that purpose.
    Now my second query is I have to get the size of the image, how will I be doing that.
    Please help me in this context.
    Thanks in advance for any help.

    Hello,
    Uploading file is a special request of HTTP.
    You have to handle the request a different way.
    Check on the JSP / Servlet forum for more information.
    Regards,
    Sebastien Degardin

Maybe you are looking for

  • SharePoint 2010 functioning incorrectly after installing Search Server Express

    Hi, and thanks for taking the time to lend a hand and your knowledge. I have a Sharepoint Foundation 2010 site that has went crazy after I tried to install Search Server Express - which FAILED near the end. I have checked the logs for the correlation

  • Sort array in TestStand

    Hi, I have an array of custom type container, something like: - TestName - Type - Operation I'd like to sort this array by Type and Operation. Is that possible in TS 2010? If not - what is the best way to do that? I'm using also LabVIEW and C/C++. Th

  • Create an ADF Tree Using a Mix of VO and Pojo?

    I am able to create a basic tree in ADF, VO1 -> VO2 -> VO3 connected by view links. Now I would like show some additional information that is not available in VO2, and the information cannot be selected directly from tables, and have to come from mak

  • Mail, SMPT problems in 10.4.7

    I know there has been a thread on the current SMTP problems with 10.4.7, but I just can't resolve the problem. Firstly, my set-up: Network: • 4 Macs (2 x G5 PPC & G5 iMac running OS X 10.4.7, G4 running OS X 10.4.6) • 1 G4 Server (OS X Server 10.3.9)

  • Joomla Site-Specific Code Hints not working, DW5

    I setup a Site using an existing Joomla installation on localhost, including the testing server and MySQL database.  After trying to enable Site-Specific Code for Joomla for this Site, I still cannot get any sort of Joomla reference or hinting while