Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > servlet - output jsp page?

Reply
Thread Tools

servlet - output jsp page?

 
 
tiewknvc9
Guest
Posts: n/a
 
      09-23-2006
hi!

is it possible for a servlet to produce a jsp page that can still run?

for instance I want to run

<%@include file="../Header.html"%>

in the page generated by the servlet. However when I do this by
response.write("..."), nothing appears on screen.

Is it possible? or is there a better way to output this file from a
servlet?

Thanks!

 
Reply With Quote
 
 
 
 
Juha Laiho
Guest
Posts: n/a
 
      09-23-2006
"tiewknvc9" <(E-Mail Removed)> said:
>hi!
>
>is it possible for a servlet to produce a jsp page that can still run?


Not necessarily; I think there could be all kinds of reloading/caching
problems.

Now, what is so dynamic on your pages that one (or few) JSP response
pages are not sufficient? I.e. handle the browser action with a servlet,
then do request.forward() to the correct JSP. To pass data processed by
the servlet, you place it in request attributes.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
 
Reply With Quote
 
 
 
 
Manish Pandit
Guest
Posts: n/a
 
      09-23-2006
Hi,

It works when you do this in a JSP but not when you write it from a
servlet because your servlet is writing "directly" to the response. In
case of a JSP, it gets compiled into a servlet first - and the JSP
engine handles the directive <%@include...%>. When you are writing
directly on the response, this text (<%@include file= %> will end up as
it is on your browser.

-cheers,
Manish

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening new child window - Running servlet (JSP and Servlet) agapitolw@yahoo.es Java 4 08-27-2007 12:57 PM
Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response javadev Java 5 11-16-2006 11:22 AM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
Using a servlet filter to modify output of a jsp? Harry Bosch Java 5 12-06-2005 06:20 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM



Advertisments