Never put static files in WEB-INF folder and never be over confident about ur analysis ;)


It could be weird but when you code in hurry to get over ASAP, it invites even more delay and trouble -I spend almost 2 hrs trying to access static files placed in a folder inside WEB-INF folder, forgetting that it will never be accessible from a browser because that’s why there exist a WEB-INF folder -to restrict public access!

So my intent was good – I had a JSP which has embedded SWF file. Everything was in root foler parellal to WEB-INF. Then I though lets restrict access to SWF using direct URL (SWF have some login code as well) – So I created a folder view “inside” WEB-INF and moved all my files there. hmm..

  1. After execution of business logic, I forwarded the request to JSP .
  2. JSP was rendered but SWF was not loaded.
  3. I tried redirect by putting the folders outside WEB-INF (For redirect it has to be out side WEB-INF!) and it worked!!!
  4. Oh my –I concluded, it’s issue with the forward, completely ignoring the fact that it’s about static file location
  5. After 2-3 hrs, yeah, 2-3 hrs, I used Firebug -I do not know why I did not used at the beginning, may be I was trying to be over smart and highly confident about my analysis of the cause!
  6. Firebug reveled that all files need to be at a place accessible by browser -which is outside WEB-INF

More than any technical learning – do not be overconfident about your analysis 😉

Advertisements

About ChandanPandey

Try to come up with a good design as by product of good coding practices

Posted on July 26, 2013, in Java and tagged , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: