Generate jsp in runtime

Discussion in 'Java' started by weetat, Apr 24, 2007.

  1. weetat

    weetat Guest

    Hi all,

    I need some advice regarding generate jsp file in runtime.
    I have a jsp web page which allowed the user the enter value for
    the fields , and , when he or she click submit , it will generate the
    jsp file according to the value entered.



    Anyone have any ideas or suggestion how to do that ?

    Thanks

    Wee Tat
     
    weetat, Apr 24, 2007
    #1
    1. Advertising

  2. Andrew Thompson, Apr 24, 2007
    #2
    1. Advertising

  3. weetat

    Kai Schwebke Guest

    weetat schrieb:
    > I need some advice regarding generate jsp file in runtime.

    ....
    >
    > Anyone have any ideas or suggestion how to do that ?


    Simply don't touch the out-of-the-box settings of tomcat
    (e.g. don't turn dynamic jsp compilation off).
    The Jasper engine will check and recompile your JSPs,
    so you just have to write the file.



    Kai
     
    Kai Schwebke, Apr 24, 2007
    #3
  4. weetat

    Lew Guest

    weetat schrieb:
    > I need some advice regarding generate jsp file in runtime.
    > I have a jsp web page which allowed the user the enter value for
    > the fields , and , when he or she click submit , it will generate the
    > jsp file according to the value entered.


    Kai Schwebke wrote:
    > Simply don't touch the out-of-the-box settings of tomcat
    > (e.g. don't turn dynamic jsp compilation off).
    > The Jasper engine will check and recompile your JSPs,
    > so you just have to write the file.


    I interpreted the original question as how to display dynamic data in a JSP
    field, not how to rewrite the JSP itself. To the OP: Is that correct?

    If so, then you don't change the JSP. JSPs by their very nature create HTML
    dynamically, so you don't have to change the JSP in order to show data
    dynamically.

    Changing a JSP is equivalent to rewriting (part of) the application. A
    well-designed application does not need to be rewritten to deal with known
    runtime situations.

    You only have to change the JSP if the layout logic changes, and not always
    even then. JSPs are inherently dynamic and do not need to be recompiled to
    show different things depending on runtime phenomena.

    The Sun JEE tutorial covers how to do this.

    --
    Lew
     
    Lew, Apr 25, 2007
    #4
  5. weetat

    Daniel Pitts Guest

    On Apr 24, 6:17 am, weetat <> wrote:
    > Hi all,
    >
    > I need some advice regarding generate jsp file in runtime.
    > I have a jsp web page which allowed the user the enter value for
    > the fields , and , when he or she click submit , it will generate the
    > jsp file according to the value entered.
    >
    > Anyone have any ideas or suggestion how to do that ?
    >
    > Thanks
    >
    > Wee Tat


    I have a suggestion.
    Don't.

    JSP's are actually compiled into Java, and then into byte code. If
    you want to have templates based on what a user enters, I would
    suggest trying a different templating technology. Google for Velocity
    or FreeMarker. Also, you might consider writing your own templating
    mechanism. JSP is not intended to be created automatically.
     
    Daniel Pitts, Apr 25, 2007
    #5
    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. Weng Tianxiang
    Replies:
    5
    Views:
    1,319
    Christophe
    Feb 16, 2006
  2. Lucia
    Replies:
    7
    Views:
    7,662
    vinny503
    Aug 19, 2011
  3. Replies:
    0
    Views:
    4,419
  4. Replies:
    3
    Views:
    417
    red floyd
    Apr 7, 2006
  5. Harlan Messinger
    Replies:
    2
    Views:
    2,308
    John Bell
    Mar 28, 2010
Loading...

Share This Page