Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Outputing JSP Code from a database

Reply
Thread Tools

Outputing JSP Code from a database

 
 
Henry F. Camacho Jr.
Guest
Posts: n/a
 
      12-05-2004
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
 
Reply With Quote
 
 
 
 
KiLVaiDeN
Guest
Posts: n/a
 
      12-05-2004

"Henry F. Camacho Jr." <> wrote in message
news: m...
> 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


 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      12-06-2004
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

 
Reply With Quote
 
hfc@ciorent.com
Guest
Posts: n/a
 
      12-11-2004
> > 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

 
Reply With Quote
 
John C. Bollinger
Guest
Posts: n/a
 
      12-13-2004
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
Collecting Data on one form and outputing it on another form Michael Mitchell via DotNetMonster.com ASP .Net 0 01-23-2005 03:14 PM
Outputing Xml from ASPX =?Utf-8?B?QWxleCBNYWdoZW4=?= ASP .Net 2 11-25-2004 07:55 AM
Error outputing results of transformation Mark Goldin ASP .Net 0 02-22-2004 10:55 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57