servlet - output jsp page?

Discussion in 'Java' started by tiewknvc9, Sep 23, 2006.

  1. tiewknvc9

    tiewknvc9 Guest

    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!
     
    tiewknvc9, Sep 23, 2006
    #1
    1. Advertising

  2. tiewknvc9

    Juha Laiho Guest

    "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.
    --
    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)
     
    Juha Laiho, Sep 23, 2006
    #2
    1. Advertising

  3. 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
     
    Manish Pandit, Sep 23, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. circuit_breaker
    Replies:
    2
    Views:
    2,063
    Jack Jia
    Apr 4, 2004
  2. DigitalUncle
    Replies:
    0
    Views:
    961
    DigitalUncle
    Nov 2, 2004
  3. javadev
    Replies:
    5
    Views:
    13,048
    javadev
    Nov 16, 2006
  4. Replies:
    4
    Views:
    829
  5. Srini
    Replies:
    1
    Views:
    222
    Mike Brind
    Oct 29, 2006
Loading...

Share This Page