Preventing multiple downloads for Java Web Start/JNLP - java

We have a Swing application which initiated from the Web application by clicking a link. The link is nothing but a JNLP url. There is a jar file hosted on our four servers under Apache. These are under a load balancer. Even though the same jar is hosted with the same time stamp but more or less every request to the JNLP the jar is gettign downloaded. Generally if there is no change in the jar the java Web start downloads only once and subsequent requests are works without downloading. What else the info it checks to compare with server version and local copy of jar?

Jar is hosted in Apache and by default apache looks at three things (timestamp+size+ETAG)
Since it is hosted in four apache servers the ETAG for each server is different and that is why it downloads whenever the request goes to one of these four servers. The fix is to remove the ETAG by overriding the apache configuration.

Related

How do I know the working directory of my apache web service?

I have a python client (ubuntu) which calls the following web service:
http://xxx.xxx.xxx.xxx:8774/v2/8d118e773c6a44c88f64960c1177ede6/getNodes'
Both client and server are located on the same machine.
How can I find to which working directory this web service (which my client is calling) is pointing to?
(I don't know the source of the web Service. All I know that it is running on the same box and its url. How do I get to the source with these two clues?)
Since it is Ubuntu, you can find all the configured Apache hosts in /etc/apache/sites-enabled. One of the files in there will be your web service, and will specify its directory.

how to access external files that are not in the web app folder using apache server

I have developed a JAVA webstart application using JNLP,am planning access jar files related jnlp from the outside webapp folder how to access those jar files.
jar files related jnlp from the outside webapp folder
Jars in the web app. directory are never meant for client distribution. They stay on the server and are protected.
A Java Web Start app. obviously needs to download all the Jars and related resources to the client, so every one of those resources must be available by URL on a public part of the server. Always make sure you can fetch the resource (Jar, JNLP, icons etc.) using a direct link in your favorite browser. If it does not allow it, neither will it work in JWS apps.

Linking external files from Java Web Server

I have a java servlet that upon a request crunches on data and produces an image. There can potentially be millions of images and once produced they don't need to be re-rendered so I'd like to cache them and avoid the render step as it is quite tedious.
I have the cacheing working fine but the problem is I need these rendered images to persist between deployments of my web application, i.e., I can't write them into the docbase or else they get destroyed upon redeployment.
What I've been doing is using the 'allowLinking' attribute of the Context as my web application is deployed as a war file (context is in META-INF/context.xml). This is somewhat tedious because I need to break the symbolic link before my application is undeployed or else the images in the link are destroyed, but it seems to work.
But this only works for Tomcat and when testing with JBoss (5.1) it doesn't seem to honor the symbolic link and doesn't allow linking to anything outside of the docbase. I'm thinking there has to be a more practical way to accomplish this that works for all Java Web Servers. What am I missing?
You could just configure a servlet that would serve the images from an external directory. This servlet would just have to extract the image file name or ID from the request, read the file from an external directory and write the bytes to the servlet response's output stream (with the appropriate content type set on the response).
Or you could add an Apache httpd server front-end which would serve the static images from some external directory, and delegate to your servlet container for the other URLs.

Downloading files from remote server Java

I am looking for suggestions on implementing this requirement:
The requirement is for users on a public website to be able to download files of any kind.
The webserver for the website resides on a DMZ, the server that stores the files is internal to our corporate network. The webserver would have to communicate with the file storage server to get the files. What would be the best way to implement this?
Map that file server as a network drive in the disk file system of the web server and then add another web application context to the servletcontainer configuration which references the network mapped path.
It's unclear what servletcontainer and platform you're running/targeting, so I can't give a more detailed answer. But if it were Tomcat, then it's a matter of adding the following <Context> element to Tomcat's /conf/server.xml, assuming that you've mapped the file server on /path/to/mount/share:
<Context path="/share" docBase="/path/to/mount/share" />
This way it's available by http://localhost:8080/share/
It looks like that you want a proxy-like component to serve backend files... Personally I wouldn't use an application server for such a task, instead use simply a webserver. Some options:
Network share: Create a network share just as BalusC proposed and configure your web server to use that share.
Reverse proxy: Deploy another web server on your file server and configure your front end to act as a reverse proxy (ie. to dispatch download requests to the internal web server)
That is to say I would rather use an (Apache, Nginx, etc.) web server based approach instead of a Java/J2EE based one. For me it seems a better fit... Hence I would consult my sysadmin:)

Process of webserver starting

This question is kind of related to our web application and it is bugging me from last few months. So we use linux server for database, application and we have our custom built java web server. If we do any change in source code of application, we build a new jar file and replace the existing jar file with new jar file. Now update to take place in live application, we just execute a HTML file which contains this kind of code :
<frameset rows="100%"?
<frame src="http://mydomain.com:8001/RESTART">
</frameset>
How does this opening of port make the application to use new jar file?
The webserver is instructed to give the /RESTART URL special treatment. This can either be through a mapping to a deployed servlet, or through a hardcoded binding to a web container action.
It is very common to have URLs with special meaning (usually protected by a password) allowing for remote maintainance, but there is no common rule set. You can see snapshots of the Tomcat Administration console at http://linux-sxs.org/internet_serving/c516.html
EDIT: I noticed you mentioned a "custom built web server". If this web server does not provide servlets or JSP's - in other words conforms to the Servlet API - you may consider raising the flag about switching to a web server which do.
The Servlet API is a de-facto industry standard which allows you to cherry-pick from a wide array of web servers from the smallest for embedded devices to the largest enterprise servers spreading over multiple physical machines, without changing your code. This means that the hard work of making your application scale has been done by others. In addition they probably even made the web server as fast as possible, and if not, you can pick another where they did.
You're sending an HTTP GET to whatever's listening on that port (presumably your web server). The servlet spec supports pre- and post-request filters, so the server may have one set up to capture this particular request and handle it in a special fashion.

Categories

Resources