Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

servlet - output jsp page?

Thread view: 
tiewknvc9 - 23 Sep 2006 15:22 GMT
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!
Juha Laiho - 23 Sep 2006 22:37 GMT
"tiewknvc9" <aotemp@hotmail.com> 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.
Signature

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)

Manish Pandit - 23 Sep 2006 23:33 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.