Hi Alexander, If you upload the file with a multipart/form-data POST, Sling will already have read the input and will provide the data in the RequestParameterMap as RequestParameter instances, which allow you access to the uploaded file data.
Hope, this helps. Regards Felix Am Montag, den 21.01.2008, 01:01 +0100 schrieb Alexander Saar: > Hi all, > I have a problem with the file upload in Sling. I have a form that > uploads a file and an according POST.jsp for handling the upload. The > log shows that POST.jsp is resolved correct, but when I try to upload > the file, I get the following exception: > > javax.servlet.ServletException: null > > org.apache.sling.scripting.resolver.impl.DefaultSlingScript.eval(DefaultSlingScript.java:97) > > org.apache.sling.servlet.resolver.helper.SlingScriptServlet.service(SlingScriptServlet.java:74) > > org.apache.sling.core.impl.request.RequestData.service(RequestData.java:415) > > org.apache.sling.core.impl.SlingMainServlet.processRequest(SlingMainServlet.java:287) > > org.apache.sling.core.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:48) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:54) > > org.apache.sling.core.impl.filter.ThemeResolverFilter.doFilter(ThemeResolverFilter.java:76) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > > org.apache.sling.core.impl.filter.LocaleResolverFilter.doFilter(LocaleResolverFilter.java:85) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > > org.apache.sling.core.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:206) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > > org.apache.sling.core.impl.SlingMainServlet.service(SlingMainServlet.java:187) > > org.apache.sling.core.impl.SlingMainServlet.service(SlingMainServlet.java:159) > > org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90) > > org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:109) > > org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:75) > javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > > org.apache.sling.launcher.webapp.SlingServlet.service(SlingServlet.java:195) > > *root cause* > > javax.script.ScriptException: null > > org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:272) > > org.apache.sling.scripting.resolver.impl.DefaultSlingScript.eval(DefaultSlingScript.java:85) > > org.apache.sling.servlet.resolver.helper.SlingScriptServlet.service(SlingScriptServlet.java:74) > > org.apache.sling.core.impl.request.RequestData.service(RequestData.java:415) > > org.apache.sling.core.impl.SlingMainServlet.processRequest(SlingMainServlet.java:287) > > org.apache.sling.core.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:48) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:54) > > org.apache.sling.core.impl.filter.ThemeResolverFilter.doFilter(ThemeResolverFilter.java:76) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > > org.apache.sling.core.impl.filter.LocaleResolverFilter.doFilter(LocaleResolverFilter.java:85) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > > org.apache.sling.core.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:206) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > > org.apache.sling.core.impl.SlingMainServlet.service(SlingMainServlet.java:187) > > org.apache.sling.core.impl.SlingMainServlet.service(SlingMainServlet.java:159) > > org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90) > > org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:109) > > org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:75) > javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > > org.apache.sling.launcher.webapp.SlingServlet.service(SlingServlet.java:195) > > *root cause* > > java.lang.IllegalStateException: getReader() has already been called for this > request > org.apache.catalina.connector.Request.getInputStream(Request.java:978) > > org.apache.catalina.connector.RequestFacade.getInputStream(RequestFacade.java:340) > > javax.servlet.ServletRequestWrapper.getInputStream(ServletRequestWrapper.java:146) > > org.apache.commons.fileupload.servlet.ServletRequestContext.getInputStream(ServletRequestContext.java:92) > > org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:329) > > org.apache.sling.core.impl.parameters.ParameterSupport.parseMultiPartPost(ParameterSupport.java:166) > > org.apache.sling.core.impl.parameters.ParameterSupport.getRequestParameterMapInternal(ParameterSupport.java:110) > > org.apache.sling.core.impl.parameters.ParameterSupport.getRequestParameter(ParameterSupport.java:87) > > org.apache.sling.core.impl.parameters.ParameterSupport.getParameter(ParameterSupport.java:68) > > org.apache.sling.core.impl.SlingHttpServletRequestImpl.getParameter(SlingHttpServletRequestImpl.java:125) > > org.apache.sling.scripting.jsp.JspServletWrapperAdapter.preCompile(JspServletWrapperAdapter.java:78) > > org.apache.sling.scripting.jsp.JspServletWrapperAdapter.service(JspServletWrapperAdapter.java:49) > > org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:126) > > org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$000(JspScriptEngineFactory.java:71) > > org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:268) > > org.apache.sling.scripting.resolver.impl.DefaultSlingScript.eval(DefaultSlingScript.java:85) > > org.apache.sling.servlet.resolver.helper.SlingScriptServlet.service(SlingScriptServlet.java:74) > > org.apache.sling.core.impl.request.RequestData.service(RequestData.java:415) > > org.apache.sling.core.impl.SlingMainServlet.processRequest(SlingMainServlet.java:287) > > org.apache.sling.core.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:48) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:54) > > org.apache.sling.core.impl.filter.ThemeResolverFilter.doFilter(ThemeResolverFilter.java:76) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > > org.apache.sling.core.impl.filter.LocaleResolverFilter.doFilter(LocaleResolverFilter.java:85) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > > org.apache.sling.core.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:206) > > org.apache.sling.core.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > > org.apache.sling.core.impl.SlingMainServlet.service(SlingMainServlet.java:187) > > org.apache.sling.core.impl.SlingMainServlet.service(SlingMainServlet.java:159) > > org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90) > > org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:109) > > org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:75) > javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > > org.apache.sling.launcher.webapp.SlingServlet.service(SlingServlet.java:195) > > Seems like somebody is calling getReader() before ParameterSupport code > is executed. But I was not able to figure out where this happens. > > Any ideas? > > Regards, > Alex >