File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes getting output from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getting output from servlet" Watch "getting output from servlet" New topic
Author

getting output from servlet

Peter Guillebaud
Ranch Hand

Joined: Jul 11, 2001
Posts: 57
Hi there,
As I understand it the servlet is meant to do the business logic - but how can you get the output, say of reading a file, from a servlet to be displayed in a jsp page?
thanks in advance
Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
servlets can output HTML
Peter Guillebaud
Ranch Hand

Joined: Jul 11, 2001
Posts: 57
sure, but I want the output to be displayed as part of a jsp page that has other stuff on it unrelated to this servlets' function...?
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
The <jsp:include/> action includes the results of page request (dynamically, as opposed to the static <@% include file="..." %> directive), so this should work for you. Try something like :
<jsp:include page="/servlet/MyServlet"/>
Let us know how you get on!
Cheers
Simon

------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
Peter Guillebaud
Ranch Hand

Joined: Jul 11, 2001
Posts: 57
Hi Simon,
Thanks very nuch for your reply. I am having problems with this I'm afraid... I get an error message as follows:
org.apache.jasper.JasperException: Invalid jsp:include tag
at org.apache.jasper.compiler.IncludeGenerator.(IncludeGenerator.java:95)
at org.apache.jasper.compiler.JspParseEventListener.handleInclude(JspParseEventListener.java:834)
at org.apache.jasper.compiler.DelegatingListener.handleInclude(DelegatingListener.java:185)
at org.apache.jasper.compiler.Parser$Include.accept(Parser.java:299)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1073)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1038)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1034)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:182)
at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:413)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:149)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:161)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:156)
at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
at java.lang.Thread.run(Thread.java

Is this likely to be a problem with the way tomcat is set up?
Jeff Sunder
Ranch Hand

Joined: Jun 26, 2001
Posts: 47
You need to add the following attribute in the jsp include:
<jsp:include page="/servlet/MyServlet"/ flush="true">
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting output from servlet