Quantcast

serving static html with Tomcat

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

serving static html with Tomcat

EDMOND KEMOKAI
Hi guys
 I am a newbee so bear with me. I have tomcat deployed on a ubuntu machine,
everything works fine except: My app generates static html pages from jsp
and writes the html files to a sub-dir of my context path, however when I
click on the link for the file, I get a 404 error. When I restart the
application after adding the file, everthing works fine, but obviously I
can't redepoly the app everytime a new html is added. I have verified that
the links are correct, Any ideas?

--

"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

Christopher Schultz-2
Edmond,

> My app generates static html pages from jsp and writes the html files
> to a sub-dir of my context path

Ugh... you are using JSP as a content-generation system? Why!?

> however when I click on the link for the file, I get a 404 error.

Can you give us an example of what the URL of the link is? Or are you
just trying to have Tomcat serve a static HTML document that you had
previously created?

Where (specifically) are you storing these generated HTML documents?

> When I restart the application after adding the file, everthing works
> fine, but obviously I can't redepoly the app everytime a new html is
> added. I have verified that the links are correct, Any ideas?

Can anyone comment on Tomcat's caching of path lookups on the disk? That
would seem to be a tremendous waste of memory if Tomcat actually
remembered that a file didn't exist (not to mention a pain in the neck
if you wanted to add files on the fly like this guy). Can someone
confirm that Tomcat does nothing of the sort? That's the only reason I
could think of for why he can't access his files.

-chris



signature.asc (258 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

EDMOND KEMOKAI
Hi Christopher

   My directory structure is as follows:
    context_path/customer/public....

   I make a call to my jsp via something to the effect:
   URL url = URL(....jsp);
   write the stream i receive to
context_path/customer/public/customer_id/index.html

    The servlet function from within which the above processing is done
should return a preview of the page to the user via
    return (new ActionForward(/customer/public/cutomer_id/index.html)); "I
am using struts by the way".
    the returned actionforward results in 404 error.

    The html is also available on the main site for searching, when i click
a link that results from the search I get the same 404 error.

    When i redeploy the app I can search and the 404 error doesn't happen
when I click a result link.

    It is as if tomcat catalogs all subfolders in your context path upon
deployment and doesn't bother actually checking the disk for files???


On 10/23/06, Christopher Schultz <[hidden email]> wrote:

>
> Edmond,
>
> > My app generates static html pages from jsp and writes the html files
> > to a sub-dir of my context path
>
> Ugh... you are using JSP as a content-generation system? Why!?
>
> > however when I click on the link for the file, I get a 404 error.
>
> Can you give us an example of what the URL of the link is? Or are you
> just trying to have Tomcat serve a static HTML document that you had
> previously created?
>
> Where (specifically) are you storing these generated HTML documents?
>
> > When I restart the application after adding the file, everthing works
> > fine, but obviously I can't redepoly the app everytime a new html is
> > added. I have verified that the links are correct, Any ideas?
>
> Can anyone comment on Tomcat's caching of path lookups on the disk? That
> would seem to be a tremendous waste of memory if Tomcat actually
> remembered that a file didn't exist (not to mention a pain in the neck
> if you wanted to add files on the fly like this guy). Can someone
> confirm that Tomcat does nothing of the sort? That's the only reason I
> could think of for why he can't access his files.
>
> -chris
>
>
>
>
>


--

"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

Mikolaj Rydzewski-2
EDMOND KEMOKAI wrote:

>   I make a call to my jsp via something to the effect:
>   URL url = URL(....jsp);
>   write the stream i receive to
> context_path/customer/public/customer_id/index.html
>
>    The servlet function from within which the above processing is done
> should return a preview of the page to the user via
>    return (new ActionForward(/customer/public/cutomer_id/index.html)); "I
> am using struts by the way".
>    the returned actionforward results in 404 error.
It's crazy. You should redesign your application.

--
Mikolaj Rydzewski      <[hidden email]>        http://ceti.pl/~miki/
                    PGP KeyID: 8b12ab02
There are three kinds of people: men, women and unix.


smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

EDMOND KEMOKAI
what's crazy about it??, the site I am creating will contain user generated
content, however the content isn't going to be changing frequently so i
didn't want to have jsp's hold objects in memory for pages that aren't
chnaging too often. I have the user publish their info whenever they make
changes to it.

On 10/23/06, Mikolaj Rydzewski <[hidden email]> wrote:

>
> EDMOND KEMOKAI wrote:
> >   I make a call to my jsp via something to the effect:
> >   URL url = URL(....jsp);
> >   write the stream i receive to
> > context_path/customer/public/customer_id/index.html
> >
> >    The servlet function from within which the above processing is done
> > should return a preview of the page to the user via
> >    return (new ActionForward(/customer/public/cutomer_id/index.html));
> "I
> > am using struts by the way".
> >    the returned actionforward results in 404 error.
> It's crazy. You should redesign your application.
>
> --
> Mikolaj Rydzewski      <[hidden email]>        http://ceti.pl/~miki/
>                     PGP KeyID: 8b12ab02
> There are three kinds of people: men, women and unix.
>
>
>
>


--

"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

Mikolaj Rydzewski-2
EDMOND KEMOKAI wrote:
> what's crazy about it??, the site I am creating will contain user
> generated
> content, however the content isn't going to be changing frequently so i
> didn't want to have jsp's hold objects in memory for pages that aren't
> chnaging too often. I have the user publish their info whenever they make
> changes to it.
I'd use a database to store user submitted data.
Or I'd use a separate directory to write files in. Separate - I mean
outside tomcat's webapps directory.

In my projects I deploy webapps only as war files and I never write
anything within app's directory.

--
Mikolaj Rydzewski      <[hidden email]>        http://ceti.pl/~miki/
                    PGP KeyID: 8b12ab02
There are three kinds of people: men, women and unix.


smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

EDMOND KEMOKAI
I'll probably end doing that, I understand apache is better for serving
static content. However the problem isn't where user data is stored, my user
data is stored in a database. Basically my app is similar to a dating
site(it is not  a dating site) where a user's profile doesn't chnage
regularly so there is no reason to use jsp for accessing such a page,
secondly, I am using lucene which can't search jsp directly. I'll eventually
install apache and use it to access html.


On 10/23/06, Mikolaj Rydzewski <[hidden email]> wrote:

>
> EDMOND KEMOKAI wrote:
> > what's crazy about it??, the site I am creating will contain user
> > generated
> > content, however the content isn't going to be changing frequently so i
> > didn't want to have jsp's hold objects in memory for pages that aren't
> > chnaging too often. I have the user publish their info whenever they
> make
> > changes to it.
> I'd use a database to store user submitted data.
> Or I'd use a separate directory to write files in. Separate - I mean
> outside tomcat's webapps directory.
>
> In my projects I deploy webapps only as war files and I never write
> anything within app's directory.
>
> --
> Mikolaj Rydzewski      <[hidden email]>        http://ceti.pl/~miki/
>                     PGP KeyID: 8b12ab02
> There are three kinds of people: men, women and unix.
>
>
>
>


--

"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

Mikolaj Rydzewski-2
EDMOND KEMOKAI wrote:
> I'll probably end doing that, I understand apache is better for serving
> static content. However the problem isn't where user data is stored,
> my user
> data is stored in a database. Basically my app is similar to a dating
> site(it is not  a dating site) where a user's profile doesn't chnage
> regularly so there is no reason to use jsp for accessing such a page,
> secondly, I am using lucene which can't search jsp directly. I'll
> eventually
> install apache and use it to access html.
Why do you insist on generating static content? Write one generic
'profile.jsp', fetch user's data from a database (you already has one)
and that's it. Have you measured that accessing db _really_ slows down
your system? If not, so don't waste your time with unneeded optimisations.

Speaking about Lucene: it's a waste of its power to index html files
generated from a database. Index text data you insert into database, not
the generated files.

--
Mikolaj Rydzewski      <[hidden email]>        http://ceti.pl/~miki/
                    PGP KeyID: 8b12ab02
There are three kinds of people: men, women and unix.


smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

Christopher Schultz-2
In reply to this post by EDMOND KEMOKAI
Edmond,

Mikolaj has a point... your are using JSP for something it was not
designed to do: generate static content. JSP was designed to generate
/dynamic/ content on the fly.

> what's crazy about it??, the site I am creating will contain user
> generated content, however the content isn't going to be changing
> frequently so i didn't want to have jsp's hold objects in memory for
> pages that aren't chnaging too often.

Since you have used the JSP to generate the content, that memory is
wasted, anyway (unless you restart the application).

> I have the user publish their info whenever they make changes to it.

Regardless of your 404 errors, might I suggest that you use a process
other than JSP to generate these files? Is it possible to have that
content dynamically generated every time from the source of "their
info"? Or are you attempting to avoid a performance problem in the future?

Some of the more foolish implementations of software have come from
people trying to solve performance problems that do not exist in the
first place.

At any rate, Tomcat /should/ be allowing you to view your files :(

I'm not sure what is wrong.

-chris



signature.asc (258 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

EDMOND KEMOKAI
In reply to this post by Mikolaj Rydzewski-2
I know premature optimization is root of some evil, but I prefer the setup I
have at the moment, I think it will work fine. I beleive I will benefit
performance wise if I don't have to do constant queries against my db, I am
not sure how much performace gain there will be. As far as indexing with
lucene, I am using a RAM index, which is updated whenever the user elects to
republish content, the index is also stored on disk in xml form so that if
the webapp has to be rebooted (which will happen invariably) it will be
parsed and reindex into RAM.

On 10/23/06, Mikolaj Rydzewski <[hidden email]> wrote:

>
> EDMOND KEMOKAI wrote:
> > I'll probably end doing that, I understand apache is better for serving
> > static content. However the problem isn't where user data is stored,
> > my user
> > data is stored in a database. Basically my app is similar to a dating
> > site(it is not  a dating site) where a user's profile doesn't chnage
> > regularly so there is no reason to use jsp for accessing such a page,
> > secondly, I am using lucene which can't search jsp directly. I'll
> > eventually
> > install apache and use it to access html.
> Why do you insist on generating static content? Write one generic
> 'profile.jsp', fetch user's data from a database (you already has one)
> and that's it. Have you measured that accessing db _really_ slows down
> your system? If not, so don't waste your time with unneeded optimisations.
>
> Speaking about Lucene: it's a waste of its power to index html files
> generated from a database. Index text data you insert into database, not
> the generated files.
>
> --
> Mikolaj Rydzewski      <[hidden email]>        http://ceti.pl/~miki/
>                     PGP KeyID: 8b12ab02
> There are three kinds of people: men, women and unix.
>
>
>
>


--

"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

Christopher Schultz-2
In reply to this post by EDMOND KEMOKAI
Edmond,

> a user's profile doesn't change regularly so there is no reason to
> use jsp for accessing such a page, secondly, I am using lucene which
> can't search jsp directly.

Lucene cannot search HTML pages directly, either. Lucene requires an
index which is separate from everything else. What you ought to do is
update your Lucene index when someone updates their profile.

I would seriously recommend re-working your site so that all content is
dynamic, and comes directly from your database. For Lucene, just make
incremental changes to your index whenever a user changes something.

Trust me: this will make your life a lot easier. You won't have to
decide what to do when previously-generated HTML documents become out of
date for some strange reason, and you have to purge and re-build every
"profile" page on your site. It's just not worth it.

-chris


signature.asc (258 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

Bill Barker-2
In reply to this post by Christopher Schultz-2

"Christopher Schultz" <[hidden email]> wrote in message
news:[hidden email]...

>Can anyone comment on Tomcat's caching of path lookups on the disk? >That
>would seem to be a tremendous waste of memory if Tomcat actually
>remembered that a file didn't exist (not to mention a pain in the neck
>if you wanted to add files on the fly like this guy). Can someone
>confirm that Tomcat does nothing of the sort? That's the only reason I
>could think of for why he can't access his files.

If you don't want it, turn it off:
     <Context cachingAllowed="false" ..... />

There is also cacheMaxSize and cacheTTL to tune Tomcat's caching of files.





---------------------------------------------------------------------
To start a new topic, e-mail: [hidden email]
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serving static html with Tomcat

Mladen Adamovic-3
In reply to this post by Christopher Schultz-2
Christopher Schultz wrote:
> I would seriously recommend re-working your site so that all content is
> dynamic, and comes directly from your database.

I agree with this. Note that if you put lots of files in file system you
will degrade app performance in most cases.
It is faster to do "select * from table where hashvalue='user1185'" than
to read /webapps/yourapp/user1185/index.jsp".

You can do in memory caching of frequently used database data to improve
app's performances.

Database app has one big advantage - scalability. In case your app is
slow you can easily make database replication and improve your app
performances.


--
Mladen Adamovic
http://www.online-utility.org 
http://www.cheapvps.info
http://www.vpsreview.com





---------------------------------------------------------------------
To start a new topic, e-mail: [hidden email]
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...