The answer is quite explicit:
Can't insert page '/pages/cannedEmail/showFile.jsp'
You are trying to *include* showFile.jsp inside another jsp file. The
other jsp file expect the included file to generate a text output. But
you are generating binary output, which can't be converted to html. I
suppose you know that, in html, you never include the binary content
inside the html document, you always create a link that points to the
document to show. In case of pictures man use <img src="..."/> tag, in
case of pdf, doc, xls man use an <object>...</object> tag.
If you look at myface example source, you should clearly notice this:
<h:graphicImage url="fileupload_showimg.jsf"/>
which is quite different from this
<jsp:include src="fileupload_showimg.jsf"/>
PS: i also notice, though you omitted to tell us about this in question,
that you are mixing JSF with tiles. Ensure tiles does not do any text
output pior ti binary output as it will give a corrupted response
(padding before start of file).
sushma sharma a écrit :
Hi Experts,
I am having trouble displaying BLOB data in my page. My requirement is
that I must be able to show some predefined types(PDF, HTML, GIF,
JPEG, DOC, XLS) of BLOB data in my page. This page must have the
header of my application. I tried to use the example given at
http://www.irian.at/myfaces/fileupload.jsf. I tried that example and
it seemed to work for Images. But after I incorporated it in my app, I
am getting the exception. Upload works, but problem is with displaying
the content of the BLOB data. We have a field in the table where we
set what type of data is in the BLOB, so I set the ContentType from that.
I am using Myfaces 1.1.5, Tomahawk 1.1.3, Ajax4Jsf 1.1.1. server is
WLS8.1 sp6.
I understand that it is a problem with the page encoding/ content type
set for the page.I tried it with UTF-8 and ISO-8859-1, but neither of
them worked. Any help is appreciated. below is my jsp file and the
exception I am getting. the jsp file is included in a tile.
Thanks,
Sushma
===================JSP File== showFile.jsp ==============================
<%@ page session="false" %>
<%
String contentType =
(String)application.getAttribute("fileupload_type");
String fileName = (String)application.getAttribute("fileupload_name");
String allowCache = request.getParameter("allowCache");
String openDirectly = request.getParameter("openDirectly");
System.out.print("\n\n*********** allowCache " + allowCache);
if(allowCache == null || allowCache.equalsIgnoreCase("false"))
{
response.setHeader("pragma", "no-cache");
response.setHeader("Cache-control", "no-cache, no-store,
must-revalidate");
response.setHeader("Expires", "01 Apr 1995 01:10:10 GMT");
}
if(contentType!=null)
{
System.out.print("\n\n*********** contentType " + contentType);
response.setContentType(contentType);
}
if(fileName != null)
{
System.out.print("\n\n*********** fileName " + fileName);
fileName = fileName.substring(fileName.lastIndexOf('\\')+1);
fileName = fileName.substring(fileName.lastIndexOf('/')+1);
StringBuffer contentDisposition = new StringBuffer();
System.out.print("\n\n*********** openDirectly " + openDirectly);
if(openDirectly==null || openDirectly.equalsIgnoreCase("false"))
{
contentDisposition.append("attachment;");
}
contentDisposition.append("filename=\"");
contentDisposition.append(fileName);
contentDisposition.append("\"");
response.setHeader ("Content-Disposition",
contentDisposition.toString());
}
byte[] bytes = (byte[])application.getAttribute("fileupload_bytes");
System.out.print("\n\n*********** fileupload_bytes ");
if (bytes != null)
{
System.out.print(" = " + bytes);
response.getOutputStream().write(bytes);
}
%>
-------------------------------Exception
-------------------------------------------------------------------------------------
Can't insert page '/pages/cannedEmail/showFile.jsp' : null
sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java:149) at
weblogic.servlet.internal.CharChunkOutput.write(CharChunkOutput.java:111)
at
weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:125)
at
weblogicservlet.jsp.BodyOutputStream.write(NestedBodyResponse.java:65) at
java.io.OutputStream.write(OutputStream.java:58) at
jsp_servlet._pages._cannedemail.__showfile._jspService(__showfile.java:168)
at
weblogic.servlet.jsp.JspBase.service(JspBase.java:33) at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1077) at
weblogic.servlet.internalServletStubImpl.invokeServlet
(ServletStubImpl.java:465) at
weblogic.servlet.internal.ServletStubImpl.invokeServlet
(ServletStubImpl.java:526) at
weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28) at
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:97)
at
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at
weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:652)
at
weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:431)
at
weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:154) at
org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137)
at
org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177) at
org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756) at
org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881)
at
org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473) at
jsp_servlet.__layout._jspService(__layout.java:260) at
weblogic.servlet.jsp.JspBase.service
(JspBase.java:33) at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1077) at
weblogic.servlet.internal.ServletStubImpl.invokeServlet
(ServletStubImpl.java:465) at
weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28) at
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:97)
at
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at
weblogic.servlet.internalRequestDispatcherImpl.forward(RequestDispatcherImpl.java:334)
at
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch
(ServletExternalContextImpl.java:419) at
org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl.dispatch
(JspTilesViewHandlerImpl.java:233) at
org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl.renderView
(JspTilesViewHandlerImpl.java:219) at
org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
at
org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandlerjava:233)
at
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute
(RenderResponseExecutor.java:41) at
org.apache.myfaces.lifecycle.LifecycleImpl.render
(LifecycleImpl.java:132) at
javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
at
org.apache.myfaces.webapp.MyFacesServlet.service(MyFacesServlet.java:77)
at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1077) at
weblogic.servlet.internal.ServletStubImpl.invokeServlet
(ServletStubImpl.java:465) at
weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28) at
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:97)
at
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
at
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
at
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
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
weblogicsecurity.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)
ebay
<http://adworks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff.com/signature-home.htm/[EMAIL PROTECTED]/1362386_1355934/1361766/1?PARTNER=3&OAS_QUERY=null%20target=new%20>