Outputing JSP Code from a database

Discussion in 'Java' started by Henry F. Camacho Jr., Dec 5, 2004.

  1. This might be crazy, but I would like to explore this.

    It is my desire to use a servlet to serve up pages from a MySQL
    database. Of course I would like to be able to use .jsp code that
    would reside in the database.

    Question:

    How do I output that jsp code that sits in the database from a
    servlet, and have it parsed by the application server?

    Thanks,

    HFC
    Henry F. Camacho Jr., Dec 5, 2004
    #1
    1. Advertising

  2. Henry F. Camacho Jr.

    KiLVaiDeN Guest

    "Henry F. Camacho Jr." <> wrote in message
    news:...
    > This might be crazy, but I would like to explore this.
    >
    > It is my desire to use a servlet to serve up pages from a MySQL
    > database. Of course I would like to be able to use .jsp code that
    > would reside in the database.
    >
    > Question:
    >
    > How do I output that jsp code that sits in the database from a
    > servlet, and have it parsed by the application server?
    >
    > Thanks,
    >
    > HFC


    You could have a Java application that could write the JSP(or HTML) files
    taken from database. All the structure.

    I've done such thing long time ago, not in Java though, to make a website
    "look like" static, by producing the pages in static HTML from the database.
    Therefore the server load was quite acceptable, because nothing was
    interpreted server-side anymore !

    But I think what you want to do is something else, and I don't think I have
    the answer for your problematic. If there is some kind of command that would
    interpret JSP code "on the flow" it'd help you I believe, good luck finding
    that information.

    K
    KiLVaiDeN, Dec 5, 2004
    #2
    1. Advertising

  3. Henry F. Camacho Jr. wrote:

    > This might be crazy, but I would like to explore this.
    >
    > It is my desire to use a servlet to serve up pages from a MySQL
    > database. Of course I would like to be able to use .jsp code that
    > would reside in the database.


    I don't see the "of course" part. Serving up straight HTML is one
    thing, as it can be passed on directly to the client, but JSP is a
    program component -- it must be compiled to a servlet, loaded, and run.
    Once that was done, the generated servlet would be likely to remain
    loaded, at least for a time, so the advantage of having the application
    server draw the source from a database would be greatly diminished.

    > Question:
    >
    > How do I output that jsp code that sits in the database from a
    > servlet, and have it parsed by the application server?


    That's the wrong question. You want to ask is "How do I make an
    application server serve JSPs whose source resides in a database instead
    of on the filesystem?" Unless you plan to write a filesystem interface
    to the database, the answer is dependent on your servlet container. For
    any particular container the answer may be that you need to modify the
    container.


    John Bollinger
    John C. Bollinger, Dec 6, 2004
    #3
  4. Henry F. Camacho Jr.

    Guest

    > > Question:
    > >
    > > How do I output that jsp code that sits in the database from a
    > > servlet, and have it parsed by the application server?

    >
    > That's the wrong question. You want to ask is "How do I make an
    > application server serve JSPs whose source resides in a database

    instead
    > of on the filesystem?" Unless you plan to write a filesystem

    interface
    > to the database, the answer is dependent on your servlet container.

    For
    > any particular container the answer may be that you need to modify

    the
    > container.


    That is a good question. I am running TomCat. I have a number of
    objects that I wrote for perl that handle navigation. The html would
    reside in a database, and my navigation handler would gather naviation
    tree from the database. I can of course output html, and I can put all
    kinds of tags to be processed by the servlet.

    At this point I would like to convert those perl objects to Java, have
    my objects handle all the navigation. Perhaps I am totally
    misunderstanding JSP, and I need to start from the ground up.

    HFC
    , Dec 11, 2004
    #4
  5. wrote:

    > That is a good question. I am running TomCat. I have a number of
    > objects that I wrote for perl that handle navigation. The html would
    > reside in a database, and my navigation handler would gather naviation
    > tree from the database. I can of course output html, and I can put all
    > kinds of tags to be processed by the servlet.


    When you write "tags to be processed by the servlet" you make me think
    you are either
    1) making things more difficult than they need to be, or
    2) misunderstanding how servlets and JSP work.

    A typical servlet front-end for a database-driven website would collect
    appropriate HTML snippets from the database (based on some local logic)
    and construct a complete HTML page from them, perhaps with the addition
    of some HTML code chosen by the servlet itself at request time.

    _Modifying_ the HTML fragments from the database at request time based
    on special tags in the HTML code would be roughly equivalent to
    server-side includes, but what would be the point of that when you're
    already running in a servlet container? A more common paradigm would be
    to write the pages as JSPs (residing locally on the server), with custom
    tags and (plain) JavaBeans encapsulating the server-side logic,
    including DB lookups.

    > At this point I would like to convert those perl objects to Java, have
    > my objects handle all the navigation. Perhaps I am totally
    > misunderstanding JSP, and I need to start from the ground up.


    It seems that the natural conversion would be from your Perl objects to
    JavaBeans that provide similar functionality. These would be usable
    whether you write the application with JSP or only with "pure" servlets.
    If you do use JSP then you might find it useful to create custom
    tags around some of the beans' features, but custom tags are a nicety,
    not a requirement.


    I repeat an important point from an earlier post that you may have not
    fully appreciated: it is *abnormal* for JSP code to be interpreted by a
    servlet container in the process of handling any specific request. The
    JSP code is translated to Java source for a servlet and compiled at
    need, but usually such need only manifests the very first time the JSP
    is accessed after its deployment (if even then).


    John Bollinger
    John C. Bollinger, Dec 13, 2004
    #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. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    Outputing Xml from ASPX

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Nov 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    340
    =?Utf-8?B?UmF2aW5kcmE=?=
    Nov 25, 2004
  2. Michael Mitchell via DotNetMonster.com

    Collecting Data on one form and outputing it on another form

    Michael Mitchell via DotNetMonster.com, Jan 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    441
    Michael Mitchell via DotNetMonster.com
    Jan 23, 2005
  3. Dan Kimhi
    Replies:
    2
    Views:
    652
    Dan Kimhi
    Feb 8, 2005
  4. Mantorok
    Replies:
    8
    Views:
    15,903
    Mantorok
    Aug 23, 2005
  5. Replies:
    3
    Views:
    386
    Teemu Keiski
    Jan 10, 2006
Loading...

Share This Page