servlet - output jsp page?

T

tiewknvc9

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!
 
J

Juha Laiho

tiewknvc9 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.
 
M

Manish Pandit

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top