FileUpload problem

Hello all,
I'm using the FileUpload component in a JSPDynPage but it does not seem to work for me. The problem is a lot like the one Patrick O'Neill asked about. I used the HTMLB example but for some strange reason variable fu remains NULL. Please have a look at my code and explain to me what the problem is. The JSP contains a file upload component and a button to start the upload event.
This is the java code I used (testprogram):
import com.sapportals.htmlb.enum.ButtonDesign;
import com.sapportals.htmlb.event.Event;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.JSPDynPage;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
import com.sapportals.portal.prt.component.IPortalComponentContext;
import com.sapportals.portal.prt.component.IPortalComponentProfile;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
// for htmlb upload
import java.io.File;
import com.sapportals.htmlb.rendering.IFileParam;
import com.sapportals.htmlb.FileUpload;
// for debugging
import com.sapportals.portal.prt.runtime.PortalRuntime;
import com.sapportals.portal.prt.logger.ILogger;
import com.sapportals.portal.prt.logger.Level;
import bean.FileUploadBean;
public class FileUploadExample extends PageProcessorComponent {
    public DynPage getPage() {
        return new RealJSPDynPage();
    public class RealJSPDynPage extends JSPDynPage {
          FileUploadBean myBean;
          private ILogger defaultLogger = PortalRuntime.getLogger();
        public RealJSPDynPage() {
        public void doInitialization() {
               // Get the request, context and profile from portal platform
                IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                IPortalComponentContext myContext = request.getComponentContext();
                IPortalComponentProfile myProfile = myContext.getProfile();
               defaultLogger.setActive(true);
               defaultLogger.setLevel(Level.ALL);
                // Initialization of bean
                FileUploadBean myBean = new FileUploadBean();
                setBeanFromProfile(myProfile, myBean);
                // Put the bean into the application context
                myContext.putValue("myBeanName", myBean);
        public void doProcessAfterInput() throws PageException {
               // Get the request, context and profile from portal platform
                IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                IPortalComponentContext myContext = request.getComponentContext();
                IPortalComponentProfile myProfile = myContext.getProfile();
                // Get the bean from application context
                myBean = (FileUploadBean) myContext.getValue("myBeanName");
                setBeanFromProfile(myProfile, myBean);
         public void doProcessBeforeOutput() throws PageException {
                    setJspName("fileupload.jsp");
          public void onClick(Event event) throws PageException {
               myBean.setText("I was clicked");
             String ivSelectedFileName;
               FileUpload fu = (FileUpload) this.getComponentByName("myfileupload");
               // debug info message, other option is: severe
               defaultLogger.info(this, "Hello this is a test");
               if (fu == null) {
                    // error
                    defaultLogger.severe(this, "strange error");
//       this is the temporary file
               if (fu != null) {
//       Output to the console to see size and UI.
                  System.out.println(fu.getSize());
                  System.out.println(fu.getUI());
                  defaultLogger.info(this, String.valueOf(fu.getSize()));
                  defaultLogger.info(this, fu.getUI());
//       Get file parameters and write it to the console
                  IFileParam fileParam = fu.getFile();
                  System.out.println(fileParam);
//       Get the temporary file name
                  File f = fileParam.getFile();
                  String fileName = fileParam.getFileName();
                  defaultLogger.info(this, fileName);
//       Get the selected file name and write ti to the console
                  ivSelectedFileName = fu.getFile().getSelectedFileName();
                  System.out.println("selected filename: "+ivSelectedFileName);
                  defaultLogger.info(this, "selected filename: "+ivSelectedFileName);
          private void setBeanFromProfile(IPortalComponentProfile myProfile, FileUploadBean myBean) {
                    // FileUpload properties
                    myBean.setSize(myProfile.getProperty("size"));
                    myBean.setMaxLength(myProfile.getProperty("maxLength"));
                    myBean.setAccept(myProfile.getProperty("accept"));
                    // Button properties
                    myBean.setDisabled(myProfile.getProperty("disabled"));
                     myBean.setDesign(ButtonDesign.getEnumByString(myProfile.getProperty("design")));
                     myBean.setEncode(myProfile.getProperty("encode"));
                     myBean.setText(myProfile.getProperty("text"));
                     myBean.setTooltip(myProfile.getProperty("tooltip"));
                     myBean.setWidth(myProfile.getProperty("width"));
This is the JSP:
<%--- FileUpload.jsp --%>
<%@ taglib uri= "tagLib" prefix="hbj" %>
<%--- Get the Bean named myBeanName from the application context --%>
<jsp:useBean id="myBeanName" scope="application" class="bean.FileUploadBean" />
<hbj:content id="myContext" >
  <hbj:page title="Template for a portal component">
   <hbj:form id="myFormId" encodingType="multipart/form-data">
     <hbj:fileUpload
                  id="myFileUpload"
                  size="<%=myBeanName.getSize() %>"
                  maxLength="<%=myBeanName.getMaxLength() %>"
                  accept="<%=myBeanName.getAccept()%>">
     </hbj:fileUpload>
     <hbj:button
          id="MyButton"
          text="<%=myBeanName.getText() %>"
          width="<%=myBeanName.getWidth() %>"
          tooltip="<%=myBeanName.getTooltip() %>"
          onClick="click"
          design="<%=myBeanName.getDesign().getStringValue() %>"
          disabled="<%=myBeanName.isDisabled() %>"
          encode="<%=myBeanName.isEncode() %>">
     </hbj:button>
   </hbj:form>
  </hbj:page>
</hbj:content>
The Bean:
package bean;
import com.sapportals.htmlb.enum.ButtonDesign;
public class FileUploadBean
     // FileUpload
     public String size;
     public String maxLength;
     public String accept;
     public String getSize() {
          return size;
     public void setSize(String size) {
          this.size = size;
     public String getMaxLength() {
          return maxLength;
     public void setMaxLength(String maxLength) {
          this.maxLength = maxLength;
     public String getAccept() {
          return accept;
     public void setAccept(String accept) {
          this.accept = accept;
     // Button
     public String disabled;
     public ButtonDesign design;
     public String encode;
     public String text;
     public String tooltip;
     public String width;
     // constructor
//     public ButtonBean() {
     public String isDisabled() {
          return disabled;
     public void setDisabled(String disabled) {
          this.disabled = disabled;
     public ButtonDesign getDesign() {
          return design;
     public void setDesign(ButtonDesign design) {
          this.design = design;
     public String isEncode() {
          return encode;
     public void setEncode(String encode) {
          this.encode = encode;
     public String getText() {
          return text;
     public void setText(String text) {
          this.text = text;
     public String getTooltip() {
          return tooltip;
     public void setTooltip(String tooltip) {
          this.tooltip = tooltip;
     public String getWidth() {
          return width;
     public void setWidth(String width) {
          this.width = width;
and the Portalapp.xml
<?xml version="1.0" encoding="utf-8"?>
<application>
  <application-config>
    <property name="startup" value="true"/>
    <property name="SharingReference" value="htmlb"/>
  </application-config>
  <components>
    <component name="FileUpload">
      <component-config>
        <property name="ClassName" value="FileUploadExample"/>
        <property name="SecurityZone" value="com.sap.portal.pdk/low_safety"/>
      </component-config>
      <component-profile>
        <property name="maxLength" value="125000">
          <property name="personalization" value="dialog"/>
        </property>
        <property name="accept" value="Accept">
          <property name="personalization" value="dialog"/>
        </property>
        <property name="size" value="50">
          <property name="personalization" value="dialog"/>
        </property>
        <property name="width" value="250">
          <property name="personalization" value="dialog"/>
          <property name="type" value="number"/>
        </property>
        <property name="disabled" value="FALSE">
          <property name="personalization" value="dialog"/>
          <property name="type" value="boolean"/>
        </property>
        <property name="encode" value="True">
          <property name="personalization" value="dialog"/>
          <property name="type" value="boolean"/>
        </property>
        <property name="tooltip" value="Initial Tooltip">
          <property name="personalization" value="dialog"/>
        </property>
        <property name="text" value="Initial Button Text">
          <property name="personalization" value="dialog"/>
        </property>
        <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
        <property name="design" value="STANDARD">
          <property name="personalization" value="dialog"/>
          <property name="type" value="select[STANDARD,SMALL,EMPHASIZED]"/>
        </property>
      </component-profile>
    </component>
  </components>
  <services/>
</application>

Hi Raymond,
within your JSP, you have given the ID "myFileUpload" whereas within your coding you try to retrieve a component with ID "myfileupload". That's all so far.
Some additinal hints:
When referring to another thread, please give the link; in this case, you talked about Problem with FileUpload component
If you give (non) working examples, please reduce them to an absolute minimum, so that they show what they should show, but nothing more. This does not only hold on SDN but for all bug tracking systems. People get ill from reading 1000 lines of code where 10 would do
And for formatting on SDN, you can use [ code ] and [/ code ] (without spaces), makes life easier too.
And don't forget to press the yellow star button on helping answers...
So far for today
Hope it helps
Detlev

Similar Messages

  • JHS 10.1.3.1.26 - FileUpLoad problem

    Hi ,
    I got a FileUpLoad problem.Here are the error messages.
    It works on local oc4j , but failed after deploying to Application Server 10.1.3.
    Any ideas ?
    Thanks.
    Eron Yang.
    java.lang.NoSuchFieldError: conn
    at oracle.ord.im.OrdDocDomain.create(OrdDocDomain.java:2108)
    at oracle.jdbc.driver.Accessor.getCustomDatum(Accessor.java:1404)
    at oracle.jdbc.driver.OracleResultSetImpl.getCustomDatum(OracleResultSetImpl.java:1347)
    at oracle.jbo.server.OracleSQLBuilderImpl.doLoadFromResultSet(OracleSQLBuilderImpl.java:1198)
    at oracle.jbo.server.AttributeDefImpl.loadFromResultSet(AttributeDefImpl.java:1633)
    at oracle.jbo.server.ViewRowImpl.populate(ViewRowImpl.java:2221)
    at oracle.jbo.server.ViewDefImpl.createInstanceFromResultSet(ViewDefImpl.java:1067)
    at oracle.jbo.server.ViewObjectImpl.createRowFromResultSet(ViewObjectImpl.java:2946)
    at oracle.jbo.server.ViewObjectImpl.createInstanceFromResultSet(ViewObjectImpl.java:2839)
    at oracle.jbo.server.QueryCollection.populateRow(QueryCollection.java:2252)
    at oracle.jbo.server.QueryCollection.fetch(QueryCollection.java:2127)
    at oracle.jbo.server.QueryCollection.get(QueryCollection.java:1501)
    at oracle.jbo.server.ViewRowSetImpl.getRow(ViewRowSetImpl.java:3650)
    at oracle.jbo.server.ViewRowSetIteratorImpl.doFetch(ViewRowSetIteratorImpl.java:2818)
    at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2674)
    at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2634)
    at oracle.jbo.server.ViewRowSetIteratorImpl.getRowAtRangeIndex(ViewRowSetIteratorImpl.java:722)
    at oracle.jbo.server.ViewRowSetImpl.getRowAtRangeIndex(ViewRowSetImpl.java:3672)
    at oracle.jbo.server.ViewObjectImpl.getRowAtRangeIndex(ViewObjectImpl.java:6288)
    at oracle.adfinternal.view.faces.model.binding.FacesCtrlRangeBinding$FacesModel._bringInToRange(FacesCtrlRangeBinding.java:541
    at oracle.adfinternal.view.faces.model.binding.FacesCtrlRangeBinding$FacesModel.setRowIndex(FacesCtrlRangeBinding.java:504)
    at oracle.jheadstart.controller.jsf.bean.JhsCollectionModel.setRowIndex(JhsCollectionModel.java:361)
    at oracle.adf.view.faces.component.UIXCollection.setRowIndex(UIXCollection.java:379)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.table.TableUtils$RowLoop.loop(TableUtils.java:85)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.table.TableUtils$RowLoop.run(TableUtils.java:58)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.DesktopTableRenderer._renderTableRows(DesktopTableRenderer.java:957)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.DesktopTableRenderer.renderTableRows(DesktopTableRenderer.java:693)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.DesktopTableRenderer.renderTableContent(DesktopTableRenderer.java:366)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.TableRenderer.encodeAll(TableRenderer.java:237)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.DesktopTableRenderer.encodeAll(DesktopTableRenderer.java:80)
    at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeEnd(CoreRenderer.java:169)
    at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624)
    at oracle.adf.view.faces.component.UIXCollection.encodeEnd(UIXCollection.java:456)
    at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeChild(CoreRenderer.java:246)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelGroupRenderer._encodeChild(PanelGroupRenderer.java:147)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelGroupRenderer._encodeChildren(PanelGroupRenderer.java:124)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelGroupRenderer.encodeAll(PanelGroupRenderer.java:72)
    at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeEnd(CoreRenderer.java:169)
    at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624)
    at oracle.adfinternal.view.faces.uinode.UIComponentUINode._renderComponent(UIComponentUINode.java:317)
    at oracle.adfinternal.view.faces.uinode.UIComponentUINode.render(UIComponentUINode.java:262)
    at oracle.adfinternal.view.faces.uinode.UIComponentUINode.render(UIComponentUINode.java:239)
    at oracle.adfinternal.view.faces.ui.composite.ContextPoppingUINode$ContextPoppingRenderer.render(ContextPoppingUINode.java:224
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:346)
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:301)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderChild(BaseRenderer.java:412)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:330)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:222)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderContent(BaseRenderer.java:129)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.render(BaseRenderer.java:81)
    at oracle.adfinternal.view.faces.ui.laf.base.xhtml.XhtmlLafRenderer.render(XhtmlLafRenderer.java:69)
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:346)
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:301)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderChild(BaseRenderer.java:412)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:330)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:222)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderContent(BaseRenderer.java:129)
    at oracle.adfinternal.view.faces.ui.laf.oracle.desktop.HeaderRenderer.renderContent(HeaderRenderer.java:489)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.render(BaseRenderer.java:81)
    at oracle.adfinternal.view.faces.ui.laf.base.xhtml.XhtmlLafRenderer.render(XhtmlLafRenderer.java:69)
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:346)
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:301)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderChild(BaseRenderer.java:412)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:330)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:222)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderContent(BaseRenderer.java:129)
    at oracle.adfinternal.view.faces.ui.laf.base.xhtml.BorderLayoutRenderer.renderIndexedChildren(BorderLayoutRenderer.java:42)
    at oracle.adfinternal.view.faces.ui.laf.base.xhtml.BorderLayoutRenderer.renderContent(BorderLayoutRenderer.java:71)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.render(BaseRenderer.java:81)
    at oracle.adfinternal.view.faces.ui.laf.base.xhtml.XhtmlLafRenderer.render(XhtmlLafRenderer.java:69)
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:346)
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:301)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderChild(BaseRenderer.java:412)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:330)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:222)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.renderContent(BaseRenderer.java:129)
    at oracle.adfinternal.view.faces.ui.BaseRenderer.render(BaseRenderer.java:81)
    at oracle.adfinternal.view.faces.ui.laf.base.xhtml.XhtmlLafRenderer.render(XhtmlLafRenderer.java:69)
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:346)
    at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:301)
    at oracle.adfinternal.view.faces.ui.composite.UINodeRenderer.renderWithNode(UINodeRenderer.java:90)
    at oracle.adfinternal.view.faces.ui.composite.UINodeRenderer.render(UINodeRenderer.java:36)
    at oracle.adfinternal.view.faces.ui.laf.oracle.desktop.PageLayoutRenderer.render(PageLayoutRenderer.java:76)
    at oracle.adfinternal.view.faces.uinode.UIXComponentUINode.renderInternal(UIXComponentUINode.java:177)
    at oracle.adfinternal.view.faces.uinode.UINodeRendererBase.encodeEnd(UINodeRendererBase.java:53)
    at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624)
    at oracle.adfinternal.view.faces.renderkit.RenderUtils.encodeRecursive(RenderUtils.java:54)
    at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeChild(CoreRenderer.java:242)
    at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeAllChildren(CoreRenderer.java:265)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelPartialRootRenderer.renderContent(PanelPartialRootRenderer.java:65
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.BodyRenderer.renderContent(BodyRenderer.java:117)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelPartialRootRenderer.encodeAll(PanelPartialRootRenderer.java:147)
    at oracle.adfinternal.view.faces.renderkit.core.xhtml.BodyRenderer.encodeAll(BodyRenderer.java:60)
    at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeEnd(CoreRenderer.java:169)
    at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624)
    at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:645)
    at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:568)
    at oracle.adf.view.faces.webapp.UIXComponentTag.doEndTag(UIXComponentTag.java:100)
    at pages.reg._Reg1130MBaseGroupTable_jspx._jspService(_Reg1130MBaseGroupTable_jspx.java:1150)
    at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.1.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
    at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:701)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:405)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:591)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:515)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher
    .java:711)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher
    .java:368)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher
    .java:287)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher
    .java:50)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher
    .java:193)
    at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:283)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher
    .java:198)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
    at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
    at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java
    :64)
    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:162)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java
    :15)
    at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:228)
    at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:197)
    at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:123)
    at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:103)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher
    .java:619)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher
    .java:368)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler
    .java:866)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler
    .java:448)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:302)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:190)
    at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor
    .java:303)
    at java.lang.Thread.run(Thread.java:595)
    07/08/13 11:28:45.78 webapp1: Servlet error

    Eron,
    This is an issue with ADF libraries, see this link for example:
    java.lang.NoSuchFieldError: conn at oracle.ord.im.OrdImageDomain
    Can you doubel check you have the correct version of ADF libs installed on your app server? Alternatively, you can try to include all ADF libs in the ear file.
    Steven Davelaar,
    JHeadstart Team.

  • File upload using apache Commons FileUpload problem

    Hi All,
    I have used Commons FileUpload for uploading files from windows to unix machine. I'm able to upload files but I have a problem about the contents of file copied in unix. When i upload files few files containing special characters are not copied correctly in unix instead ascii codes are getting copied/written. Seems to be a problem with character encoding.
    For example symbol "�" is not getting copied correctly in unix. So as new line character to. If anyone has faced such issues kindly provide few pointers on this. Appreciate your guidance.
    Thanks,
    -Aj

    Thanks for the reply.
    I'm using the Commons FileUpload class "FileItem" which holds the filestream data and using function
    code snippet of file upload
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    Iterator it = fileItemsList.iterator();
    while (it.hasNext())
         FileItem fileItemTemp = (FileItem)it.next();
         File saveToFile = new File("newFile");
          fileItem.write(saveToFile ); // write fileItem data to saveToFile.
    } FileItem object takes care of writing data to disk.No idea,how it does internally.
    Thanks,
    -Aj.

  • FileUploading problem

    hi all,
    My problem is to upload a file to a folder in the server(WAS).
    i took an attribute data with type binary, and also a attribute for filename with type string.also binded them with the fileupload ui element.
    the code i wrote is:
    on action submit{
    IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(IPrivateUploadfiletob.IContextElement.FILERESOURCE);
         IWDModifiableBinaryType binarytype=(IWDModifiableBinaryType)attributeInfo.getModifiableSimpleType();
         IPrivateUploadfiletob.IContextElement element=wdContext.currentContextElement();
         if(element.getFileresource()!=null)
         try{
         String mimetype=binarytype.getMimeType().toString();
         byte[] file=element.getFileresource();
         //String pat="D:
         //String fullpath = pat+element.getFilename();
         File file1 = new File("c:
    Resume.doc");
         FileOutputStream fos = new FileOutputStream(file1);
         fos.write(file);
         fos.close();
    when i am running it i am getting an error as:
    com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: <b>c:\Resume.doc (Access is denied)</b>     at com.satyam.fileuploadproject.Uploadfiletob.onActionSubmit
    But when i am running it withoutC:
    i.e,, simply if i give the file name(anyname) it is saying file got stored.
    Can any one tell me When u click on submit  where is it exactly going and stored
    according to wat i wrote plzzzzzzzz
    thanks in advance.
    kavita

    It gets stored in the following directory :
    /temp/webdynpro/web/local/<Project Name>/Components/<Component package>/<file>.
    Regards,
    Subramanian V.

  • FileUpload problem: InputStream does not contain a serialized object

    Hi All,
    I'm using the FileUpload component in a JSPDynPage and the htmlb component seems to work fine but I cannot read the file (InputStream). I get the following error(IOException): "InputStream does not contain a serialized object".
    Please let me know what is wrong with my code. This is a part of the code I used:
    public FileInputStream sourceFileInput;
    public ObjectInputStream input;
    FileUpload fu;
    fu = (FileUpload) this.getComponentByName("myFileUpload");
    IFileParam fileParam = ((FileUpload) getComponentByName("myFileUpload")).getFile();
    File f       = fileParam.getFile();
    file         = fu.getFile().getFile();
    absolutepath = fu.getFile().getFile().getAbsolutePath();
    this.sourceFileInput = new FileInputStream(file);
    input = new ObjectInputStream(sourceFileInput);
    The last line of code seems to generate te error.

    Hi,
    I have found the answers, thank you both.
    (I included the examle code. Perhaps of some use to someone.)
    FileUpload fu;
    fu = null;
    fu = (FileUpload) this.getComponentByName("myFileUpload");
    //       this is the temporary file
    if (fu != null) {
         IFileParam fileParam = ((FileUpload) getComponentByName("myFileUpload")).getFile();
         if (fileParam != null) {
              // get info about this file and create a FileInputStream
              File f = fileParam.getFile();
              if (f != null) {
                   try {
                        fis = new FileInputStream(f);
                   // process exceptions opening files
                   catch (FileNotFoundException ex) {
                        myBean.setMessage(
                             "1" + f + ex.getLocalizedMessage());
                   isr = new InputStreamReader(fis);
                   br = new BufferedReader(isr);
    String textLine = "";
    do {
         try {
              textLine = (String) br.readLine();
         } catch (IOException e) {
              myBean.setMessage(
                   "1" + e.getLocalizedMessage());
         // Jco append table & put data into the record
         // (I_FILE is the table with txt data that is sent to the RFC)
         I_FILE.appendRow();     
         I_FILE.setValue(textLine, "REC");                              
    } while (textLine != null);

  • Commons FileUpload problem

    Hello. I want the user to be able to upload a file, and then I want to read the file and do some stuff with it.
    I searched around and found out that to do this I needed to use a third party library. I found the Commons FileUpload, but I cant seem to make it work. I tried to use the mailing list, but I have gotten no respons.
    In the jsp
    ***uploadPhoto.jsp ***
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@ page import="org.apache.commons.fileupload.*"%>
    <%@ page import="org.apache.commons.fileupload.servlet.*"%>
    <%@ page import="org.apache.commons.fileupload.portlet.*"%>
    <%@ page import="org.apache.commons.collections.*"%>
    <%@ page import="java.util.*"%>
    <%
         boolean isMultipart = ServletFileUpload.isMultipartContent(request);
         out.println("" + isMultipart);
    //      Parse the request
         FileItemIterator iter = upload.getItemIterator(request);
         while (iter.hasNext()) {
             FileItemStream item = iter.next();
             String name = item.getFieldName();
             InputStream stream = item.openStream();
             if (item.isFormField()) {
                 out.println("Form field " + name + " with value "
                     + StreamUtil.asString(stream) + " detected.");
             } else {
                 out.println("File field " + name + " with file name "
                     + item.getName() + " detected.");
                 // Process the input stream
    %>The first line returns true. So I know I have a file. But the next one I get an error saying "Cannot find type FileItemIterator.
    I tried to include as much libraries as I thought needed, but still the same error.
    I have put the commons fileupload jar in my WEB-INF/lib directory, and also in my application.jar file.
    Can someone help me please?
    Message was edited by:
    asgshe

    Yes I found this out right before you posted it.
    I think the documentation is very poor. No where did
    it say that I needed this. Luckily I read a post here
    that someone had suggested this.I have to disagree on that! It is mentioned here: http://jakarta.apache.org/commons/fileupload/using.html and here: http://jakarta.apache.org/commons/fileupload/dependencies.html
    Where else should they mention it?

  • Commons fileupload problem with Jdeveloper

    Hi,
    I tried to use commons fileupload with jdeveloper and I have put those two jar files under web-inf/lib directory. but it did not work. Anyone can help? Thanks in advance. Error code is shown below:
    Error(79,33): illegal start of expressionError: cannot access class org.apache.commons.fileupload.FileItem; file org\apache\commons\fileupload\FileItem.class not found
    Error: cannot access class org.apache.commons.fileupload.FileItemFactory ; file org\apache\commons\fileupload\FileItemFactory.class not found
    Error: cannot access class org.apache.commons.fileupload.FileUpload; file org\apache\commons\fileupload\FileUpload.class not found
    Error: cannot access class org.apache.commons.fileupload.disk.DiskFileItemFactory ; file org\apache\commons\fileupload\disk\DiskFileItemFactory.class not found
    Error: cannot access class org.apache.commons.fileupload.servlet.ServletFileUpload; file org\apache\commons\fileupload\servlet\ServletFileUpload.class not found
    Error: cannot access class org.apache.commons.fileupload.FileUploadBase; file org\apache\commons\fileupload\FileUploadBase.class not found
    Error: cannot access class org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; fileorg\apache\commons\fileupload\FileUploadBase\SizeLimitExceededException.class not found
    Error(25,29): variable ServletFileUpload not found in class _upload
    Error(31,7): class DiskFileItemFactory not found in class _upload
    Error(31,41): class DiskFileItemFactory not found in class _upload
    Error(43,7): class ServletFileUpload not found in class _upload
    Error(43,38): class ServletFileUpload not found in class _upload
    Error(52,15): class SizeLimitExceededException not found in class _upload
    Error(61,7): class FileItem not found in class _upload
    Error(61,24): class FileItem not found in class _upload                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Are you sure you have the full JDK or just JRE?
    Check the size of the jar you downloaded to make sure it downloaded complete.
    Basic install instructions are here:
    http://download.oracle.com/docs/cd/E14571_01/install.1111/e13666/ojdig.htm#BDCJDDFE

  • Myfaces fileupload problem

    Dear All,
    I am using myfaces <t:inputFileUpload>
    < t:inputFileUpload storage="file" value="#{myBean.file}" required="true"/>
    <h:commandButton value="Submit" action="#{myBean.upload}"/>
    to upload file to a server. When I use localhost as the server (http://localhost:8080), I can upload file to my PC. But when I use a web server (http://www.myServer.com:18080) I cannot upload the file to a directory on myServer. I guess this is because myServer cannot get the file - do I need to use request object to get the file? If so, how do I use it? Can someone show me an example please?
    Thank you very much
    Regards
    Mary

    I assume, that after upload U want to save this file in some place on this server right ?
    JSF:
    <h:form id="f_load_temp_jr" enctype="multipart/form-data">
         <x:inputFileUpload id="file_upload"
              value="#{MyBean.myFile}"                          
              required="true" />
         <h:commandButton value="Send file" action="#{MyBean.sendFile}/>
    <h:form>MyBean -just some more important parts ofcourse:
    import org.apache.myfaces.custom.fileupload.UploadedFile;
    private UploadedFile    myFile;
    public String sendFile(){
    try{
    //first create dir for file - not needed ofcourse
         File fileOnServer = new File("c:/temp");
            fileOnServer.mkdirs();
    //create empty file with specified name and path
            fileOnServer = new File("c:/temp/"+myFile.getName());
    //now we gonna save uploaded file into new one
         BufferedOutputStream os = new BufferedOutputStream(new             FileOutputStream(fileOnServer));
         BufferedInputStream is = new BufferedInputStream(myFile.getInputStream());
         byte[] buffer = new byte[1024];
         int count = 0;
         while ((count = is.read(buffer)) != -1) {
                    os.write(buffer, 0, count);
         os.close();
         is.close();
    }catch(Exception e){
      e.printStackTrace();
    ...Now we've created file on c:/temp/uploaded_file_name :)
    I don't know how can I explain this more simply, hope it's gonna help U.
    Martin

  • Jakarta fileupload problems

    hi it's keeps saying request doesn't have multipart can't figure out why
    form action="Admin" name="myForm" enctype="multipart/form-data" >
              <input type="hidden" name="action" id="action" value="addNewFileArticle">
              <input type="file" name="articleFile"><br>
    in the jsp and in the servlet i'm falling in the last line :
    //Create a factory for disk-based file items
                   DiskFileItemFactory factory = new DiskFileItemFactory();
                   // Set factory constraints
                   //factory.setSizeThreshold(yourMaxMemorySize);
                   File file = new File("articles/");
                   if (!file.exists())
                        file.createNewFile();
                   System.out.println("file "+file.getAbsolutePath());
                   factory.setRepository(file);
                   // Create a new file upload handler
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   // Set overall request size constraint
                   //upload.setSizeMax(d);
                   //Parse the request
                   List items = upload.parseRequest(req);guys this is realy important i'm on a tight scheduele and would very much appreciate any help , thanks in advance.

    You're getting this message when you try to compile the servlet, right? Make sure that jar file is in your classpath. Having it in Tomcat's classpath is fine for when Tomcat runs things but it has nothing to do with compiling.

  • Problem in FIleUpload using myfaces-Tomhawk

    Hi,
    I am facing problem in implementing FileUpload.I am using Tomhawk and did everything as mentioned in the docs.I am getting the following error:
    java.lang.NoClassDefFoundError: javax/servlet/jsp/el/ELException
         at org.apache.myfaces.shared_tomahawk.config.MyfacesConfig.(MyfacesConfig.java:94)
         at org.apache.myfaces.renderkit.html.util.AddResourceFactory.getInstance(AddResourceFactory.java:282)
         at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:126)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7053)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
    Any Help is appreciated

    For JSF 1.2 based frameworks you need el-api.jar and el-ri.jar.

  • FileUpload and special characters problem

    Dear all,
    I currently encounter a issue with the FileUpload module.
    In my user form I have a FileUpload module to enable the user to upload a certificate file. The module itself is working fine but when the user controls an organisation containing a special character (like ñ), I cannot save the form because of the following error :
    ( ) - Warning: Parenthesized values in field 'accounts[Lighthouse].controlledOrganizations' do not match any of the allowed values.
    No controlled organisation is parenthesized.
    If I remove the FileUpload module, there is no error and I can save the user.
    If I change the type of the FileUpload module to Text, there is no error and I can save the user.
    I have two environments with this problem and two other without but the forms are identical, the java classes are the same. I do not see what would be able to cause this behaviour.
    Do you have any idea how to fix this ?
    It looks like the issue reported in this thread Problem using FileUpload Class Element/ encoding/ umlaut problem
    Thanks

    Try to use parameters instead hardcoding values in the queries:
    select * from user where lower(username)=?;
    and don't forget to lower the value from java side as well ;-)

  • Problem with commons-fileupload library.

    Hello,
    I'm using the following code to try and upload files to my Tomcat server from HTTP clients. The code is inside a JSP page. When I submit the form to this jsp page, I get no errors but the file is not being uploaded and the only out.println statement that is printing is the first one that tests if the form is multi-part. It prints true.
         boolean isMultipart = FileUpload.isMultipartContent(request);
         out.println("" + isMultipart);
         if (isMultipart) {
              DiskFileUpload upload = new DiskFileUpload();
              upload.setSizeThreshold(2000000);
              upload.setSizeMax(5000000);
              int sizeThresh = 2000000, sizeMax = 5000000;
              String dir = "c:/temp";
              List items = upload.parseRequest(request, sizeThresh, sizeMax, dir);
              Iterator iter = items.iterator();
              while (iter.hasNext()) {
                   FileItem item = (FileItem) iter.next();
                   out.println(item.getFieldName());
                   if (item.isFormField()) {
                        continue;
                   else {
                        String fieldName = item.getFieldName();
                        String fileName = item.getName();
                        String contentType = item.getContentType();
                        boolean isInMemory = item.isInMemory();
                        long sizeInBytes = item.getSize();
                        out.println("Info: " + sizeInBytes + " " + contentType + " " + fileName + " " + fieldName);
                        File uploadedFile = new File("test.txt");
                        item.write(uploadedFile);
         } Any idea what my problem is?
    Thanks.

    Sorry to keep posting but this gets more complex. Here's the deal.
    The UploadBean works on both Tomcat 4 and Tomcat 5 as long as the code below has not been called yet for the user's session. It is code that asks the browser for authentication. Once this code has been called for the current session, the Upload Bean no longer works.
    Any idea what would cause this?
    package com.biscuit.servlets;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * NTLM authorization (Challenge-Response) test servlet.
    * Requires IE on the client side.
    * In order to avoid browser log on dialog box User Authentication/Logon
    * settings should be set to:
    * <ol>
    * <li>Automatic logon in Intranet zone or</li>
    * <li>Automatic logon with current username and password</li>
    * </ol>
    * Based on information found on jGuru WEB site:
    * http://www.jguru.com/faq/viewquestion.jsp?EID=393110
    * @author Leonidius
    * @version 1.0 2002/06/17
    public class NTLMTest extends HttpServlet{
         // Step 2: Challenge message
         final private static byte[] CHALLENGE_MESSAGE =
              {(byte)'N', (byte)'T', (byte)'L', (byte)'M', (byte)'S', (byte)'S', (byte)'P', 0,
              2, 0, 0, 0, 0, 0, 0, 0,
              40, 0, 0, 0, 1, (byte)130, 0, 0,
              0, 2, 2, 2, 0, 0, 0, 0, // nonce
              0, 0, 0, 0, 0, 0, 0, 0};
         * HTTP request processing
         protected synchronized void service(HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException{
              PrintWriter out = response.getWriter();
              try{
                   String auth = request.getHeader("Authorization");
                   if (auth == null) {
                        response.setContentLength(0);
                        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
                        response.setHeader("WWW-Authenticate", "NTLM");
                        response.flushBuffer();
                        return;
                   if (!auth.startsWith("NTLM ")) return;
                   byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
                   // Step 1: Negotiation message received
                   if (msg[8] == 1) {
                        // Send challenge message (Step 2)
                        response.setContentLength(2);
                        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
                        response.setHeader("WWW-Authenticate",
                        "NTLM " + new sun.misc.BASE64Encoder().encodeBuffer(CHALLENGE_MESSAGE));
                        out.println(" ");
                        response.flushBuffer();
                        return;
                   // Step 3: Authentication message received
                   if (msg[8] == 3) {
                        int off = 30;
                        int length, offset;
                        length = (msg[off+1]<<8) + msg[off];
                        offset = (msg[off+3]<<8) + msg[off+2];
                        String domain = new String(msg, offset, length);
                        domain = removeBlanks(domain).toUpperCase();
                        length = (msg[off+9]<<8) + msg[off+8];
                        offset = (msg[off+11]<<8) + msg[off+10];
                        String user = new String(msg, offset, length);
                        user = domain + "\\" + removeBlanks(user).toUpperCase();
                        HttpSession session = request.getSession(true);                    
                        session.setAttribute("userID", user);                    
                        String forwardAddress = "home";     
                        RequestDispatcher dispatcher = request.getRequestDispatcher(forwardAddress);
                        dispatcher.forward(request, response);
    //                    length = (msg[off+17]<<8) + msg[off+16];
    //                    offset = (msg[off+19]<<8) + msg[off+18];
    //                    String ws = new String(msg, offset, length);
    //                    ws = removeBlanks(ws);
    //                    response.setContentType("text/html");
    //                    out.println("<html>");
    //                    out.println("<head>");
    //                    out.println("<title>NT User Login Info</title>");
    //                    out.println("</head>");
    //                    out.println("<body>");
    //                    out.println(new java.util.Date() + "<br>");
    //                    out.println("Server: " + request.getServerName() + "<br><br>");
    //                    out.println("Domain: " + removeBlanks(domain) + "<br>");
    //                    out.println("Username: " + removeBlanks(user) + "<br>");
    //                    out.println("Workstation: " + removeBlanks(ws) + "<br>");
    //                    out.println("</body>");
    //                    out.println("</html>");
              catch (Throwable ex){
                   ex.printStackTrace();
         }//service
         * Removes non-printable characters from a string
         private synchronized String removeBlanks(String s){
              StringBuffer sb = new StringBuffer();
              for (int i = 0; i < s.length(); i++) {
                   char c = s.charAt(i);
                   if (c > ' ')
                   sb.append(c);
              return sb.toString();
    }//class NTLMTest

  • Problem with hx:fileupload

    Hello!
    I have a new problem. I'm using a hx:fileupload tag, but when I write in this input text intead of selecting the browse button I get a javascript error. I have read that is a problem only with IE, so I need to make readonly this field.
    I have also read that a readonly is not easy for an input type file, I have found a solution here
    http://www.codeguru.com/forum/archive/index.php/t-197501.html
    but when I have tried the solution I find a new error, when I click over a submit file my hx:fileuploadis clear and a submit is not executed.
    I don�t know why my file is clear.
    Can someone help me again
    thanks

    Sorry, I have no solution for you but I do have the same problem. I have been searching every java site/forum I could found for a solution but no luck so far.
    As soon as the �DiskFileUpload upload = new DiskFileUpload()� line is executed the program crash with a NoClassDefFoundError: javax/servlet/ServletInputStream. There is no problem creating a ServletInputStream object though. I would also appreciate it very much if anyone could give us any ideas on what might cause this error.

  • Jakarta Commons FileUpload ; Internet Explorer Problem

    Hi all,
    Environment:
    Tomcat 5 ;Apache 2; JDK 1.5.0; Jakarta Commons Fileupload 1.0
    OS: Windoze XP
    Previously I've used jakarta commons fileupload package to succussfully to upload a file.
    However, I am trying to check the content type of the file and throw an exception if its not a jpeg file. The following code works great when I use firefox. But it fails when I use Internet Explorer!
    When I supply an existing jpg file on my desktop as the input to the HTML form, the code works fine. However if I enter a non-existing jpg filename, I get a "HTTP 500 Internal Server Error"! I expect to get the "Wrong content type!" message (which my JSP throws as an exception and should be caught by the error page). This problem happens only with Internet Explorer. With firefox, I get the "Wrong Content Type" message as expected.
    What could be the problem? Please advise.
    Thanks
    Joe.
    Code follows......
    /************** file-upload.html *************/
    <!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>File Upload</title>
    <script type="text/javascript" language="JavaScript">
    <!--
    function fileTypeCheck() {
         var fileName = document.uploadForm.pic.value;
         if (fileName == "") {
              alert ("Please select a file to upload!");
              return false;
         var indexOfExt = fileName.lastIndexOf (".");
         if (indexOfExt < 0) {
              alert('You can only upload a .jpg/.jpeg/.gif file!');
              return false;
         var ext = fileName.substring(indexOfExt);
         ext = ext.toLowerCase();
         if (ext != '.jpg' && ext != 'jpeg') {
             alert('You selected a ' + ext + ' file;  Please select a .jpg/.jpeg file instead!');
              return false;
         return true;
    //--></script>
    </head>
    <form action="uploadPhoto.jsp" enctype="multipart/form-data" method="post" name="uploadForm" onSubmit="return fileTypeCheck();">
         <input type="file" accept="image/jpeg,image/gif" name="pic" size="50" />
         <br />
         <input type="submit" value="Send" />
    </form>
    <body>
    </body>
    </html>
    /*************** photoUpload.jsp **************/
    <%@ page language="java" session="false" import="org.apache.commons.fileupload.*, java.util.*" isErrorPage="false" errorPage="uploadPhotoError.jsp" %>
    <%!
    public void processUploadedFile(FileItem item, ServletResponse response) throws Exception {
         try {
              // Process a file upload
                  String contentType = item.getContentType();
              if (! contentType.equals("image/jpeg") && ! contentType.equals("image/pjpeg")) {
                   throw new FileUploadException("Wrong content type!");
         } catch (Exception ex) {
              throw ex;
    %>
    <%
    // Check that we have a file upload requeste
    boolean isMultipart = FileUpload.isMultipartContent(request);
    // Create a new file upload handler
    DiskFileUpload upload = new DiskFileUpload();
    // Parse the request
    List /* FileItem */ items = upload.parseRequest(request);
    // Process the uploaded items
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();
        if (! item.isFormField()) {
            processUploadedFile(item, response);
    %>
    <html>
    <head>
    </head>
    <body>
    File uploaded succesfully! Thank you!
    </body>
    </html>
    /******** uploadPhotoError.jsp ****/
    <%@ page language="java" session="false" isErrorPage="true" %>
    <html>
    <head>
    </head>
    <body>
    <%
    out.println(exception.getMessage());
    %>
    </body>
    </html>

    I just found out that the problem that I have mentioned in my previous post has nothing to do with Jakarta Commons Fileupload. It happens whenever I try throwing an exception. And it happens only when I use Internet Explorer
    Thanks,
    Joe
    See the code below...
    /**** throw-error.jsp ***/
    <%@ page language="java" session="false" isErrorPage="false" errorPage="catch-error.jsp" %>
    <%
    throw new Exception("Catch this!");
    %>
    /****** catch-error.jsp ****/
    <%@ page language="java" session="false" isErrorPage="true" %>
    <html>
    <head>
    </head>
    <body>
    <%
    out.println(exception.getMessage());
    %>
    </body>

  • PROBLEM IN INTERNET EXPLORER WITH THE  fileupload API

    i written a servlet to upload a file which will upload a file to a specific directory..............
    this program is working with opera or Mozilla browser.......but it is not working in internet explorer 8.
    i can not understand what is the problem..............
    code working with opera or Mozilla and also for other browser but not with explorer 8..
    my code is
    index.jsp is a welcome file which is used to select a file  which i want to upload
    index.jsp
    <html>
    <head><title>Upload page</title></head></p> <p><body>
    <form action="uploadFile" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <center>
    <table border="2">
    <tr>
         <td align="center"><b>Multipale file Uploade</td>
         </tr>
    <tr>
         <td>
              Specify file: <input name="file" type="file" id="file">
         <td>     </tr>
         <tr>
         <td>
    <div align="center">
    <input type="submit" name="Submit" value="Submit files"/>
    </div></td>
    </table>
         <center>
    <p>
         </p>
    </form>
    </body>
    </html>
    uploadFile.java is servlet file which is used to upload the file in the specific location....
    the code of uploadFile.java is
    uploadFile.java
    import java.io.IOException;
    import java.util.Iterator;
    import java.lang.Object;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.List;
    import java.io.*;
    import java.io.File;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory ;
    import org.apache.commons.fileupload.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class uploadFile extends HttpServlet
    public void doPost(HttpServletRequest request,HttpServletResponse response)
    throws IOException,ServletException {
    HttpSession session=request.getSession();
    PrintWriter out=response.getWriter();
    ServletConfig config=getServletConfig();
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    if(!isMultipart)
    else
         FileItemFactory factory = new DiskFileItemFactory();
         ServletFileUpload upload = new ServletFileUpload(factory);
         List items = null;
         try {
              items = upload.parseRequest(request);
         } catch (FileUploadException e) {
              e.printStackTrace();
         Iterator itr = items.iterator();
         while (itr.hasNext()) {
         FileItem item = (FileItem) itr.next();
         if (item.isFormField()) {
         } else {
              try {
                   String itemName = item.getName();
                   if(itemName.equals(""))
                   session.setAttribute("itemName",itemName);
                   response.sendRedirect("index.jsp");
                   File savedFile = new File(config.getServletContext().getRealPath("/")+"uploadedFiles/"+itemName);
                   item.write(savedFile);
                   out.println("Your file has been saved at the loaction:"+"\n"+config.getServletContext().getRealPath("/")+"uploadedFiles"+"\\"+itemName);
              } catch (Exception e) {
                   e.printStackTrace();
    Now i want to solve my problem in my code...............
    pleasde help me.............

    First of all, please do not shout in topic titles. It is rude.
    Secondly, please buy a new keyboard. Your dot key hangs all the time, it reads annoying.
    Back to your problem: did you read the FAQ available at the [FileUpload homepage|http://commons.apache.org/fileupload]? There´s something stated about a misbehaviour in IE and how to fix it using Commons IO. It is namely sending the complete client´s file path instead of only the file name.

Maybe you are looking for

  • Ipod nano 4 with i mac G3 400

    I'm Italian, i have buy e new i pod nano and i have a problem to connecting the i pod with my i mac g3 400 mhz with mac os x 10.2.8 and i have itunes 6, i want to connect my i Pod for to transfer the mp3 file that i have in my imac; when i connect th

  • Smartform to pdf conversion and send as attachment

    Hi, my requirement is i have to change the smartform to pdf and send as attachment to mail id's. For specified smartform it is converting and sending as pdf but in my selection screen i have to give smartform name and mail id's. if i give any other s

  • Error: value too large for column ?!?

    I use LKM SQL to Oracle and IKM Oracle Incremental Update. When I execute the interface I get an error message: 12899 : 72000 : java.sql.BatchUpdateException: ORA-12899: value too large for column "SAMPLE"."C$_0EMP"."C4_EMP_NM" (actual: 17, maximum:

  • 648 Max no booting (all leds are RED)

    Hello, I use my 648 Max mother board for 2 year with : - P4 @ 2,4 Ghz - two PC2700 DDR 512 Mo - the D-Bracket 2 - two hard disk - a nvidia g-force 2 - a lan pci - sound blaster live! 5.1 Since yesterday, my computer don't start (whithout hardware cha

  • Unable to access my Administrator User Account with my CORRECT password.

    The correct password for the Peter Thiess Administrator User account is bandicoot. All I get is the jiggle. I managed to change the password for the account by booting up with OS X Installer disk with the "C" key. Went to Utilities - reset password.