File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Using Servlet in <welcome-file-list> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using Servlet in <welcome-file-list>" Watch "Using Servlet in <welcome-file-list>" New topic
Author

Using Servlet in <welcome-file-list>

Balaji Ramalingam
Greenhorn

Joined: Nov 08, 2004
Posts: 9
I faced a problem of IE caching the JSP Pages. I tried to solve this problem by introducing <meta tags in JSP but that did not work out. I found that there was a new feature that is introduced as part of servlet 2.4 spec. - using servlet in welcome-file-list in web.xml.

So, introduced a servlet and gave that as an entry in ><welcome-file>



Does any body see drawbacks in using a Servlet as Welcome-file? Please let me know...


Thanks,
Balaji
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

How is that going to solve your caching problem?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Balaji Ramalingam
Greenhorn

Joined: Nov 08, 2004
Posts: 9
Probably, I understated the problem. We were trying to download a jnlp file when user enters a URL. JNLP File is an XML Document. We have an attribute max-heap-size as part of a tag in JNLP File. When user hits a URL, we got to download the JNLP File. But before downloading to client, we got to modify the max-heap-size attribute if there was any user entered value for it(we have a separate gui where user can enter memory heap that client want to use).



So, whenever user hits the URL, http://IP:PORT/Test we would download the JNLP file. We are doing post processing using a Filter to modify the response provided by JNLPDownloadServlet(provided by javawebstart) to make use of the user entered max-heap-size value.

For the first time, it works fine. But when i modified the max-heap-size thru the gui (same web-app with admin previlege) and tried to download this jnlp file, it was still using the same file. I found that it was not hitting the Filter every time.

As we are always requesting for a resource(Test.jnlp that is not at modified) I observed that HTTPServer caches the file and not at all forwarding the request to WebServer. Only if the request is forwarded to the webserver, it would try to download the jnlp file again.

As the resource is already cached and available with HTTP Server, request is served by HTTP Server. So, I introduced a servlet to solve this problem.

Thats where the proposed solution comes to picture.




So, From HTTP Server perspective, we would always be trying to execute a servlet and not a resource, so it is not caching the jnlp file. It always hits the servlet This solved caching problem.


Let me know if there is any drawback in this approach.


Thanks,
Balaji



Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I would, first, make sure that all the no-cache headers are set.
If that didn't work, I would modify the links to the JNLP page to make sure that they are always unique.
A querystring variable with a timestamp for a value will usually do the trick.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
i would suggest to call your home page using a fake parameter that changes for each request such as getting the date using javascript

the algorithm would be like this in your home pages for example index.html


1) create a random value such as getting the time using jascript
2) redirect to the same page using javascript but this time passing the value you got on (1) ... something like this index.html?ts=<current time value>
3) ofcourse you must add some logic in your page so that it will not keep redirecting ... for example if it don't find a "ts" in the querystring then redirect using points 1 and 2.


hope it work ;)


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
Balaji Ramalingam
Greenhorn

Joined: Nov 08, 2004
Posts: 9
Hi Ben,

I tried with all the meta tags with no cache headers. But that did not work out.


If that didn't work, I would modify the links to the JNLP page to make sure that they are always unique.


Could you please elaborate a bit more on this?


Thanks,
Balaji
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489


As we are always requesting for a resource(Test.jnlp that is not at modified) I observed that HTTPServer caches the file and not at all forwarding the request to WebServer. Only if the request is forwarded to the webserver, it would try to download the jnlp file again.


Isnt this a configuration issue? If you are proxying requests through a http server, you should be able to specify which kind of resources to cache on the http server and which should be forwarded to the webserver. Such settings are configurable on IIS and apache.

ram.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Servlet in <welcome-file-list>