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 Need to refer a Javascript from another WAR file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Need to refer a Javascript from another WAR file" Watch "Need to refer a Javascript from another WAR file" New topic
Author

Need to refer a Javascript from another WAR file

Baranidharan Ramakoti
Greenhorn

Joined: Aug 14, 2007
Posts: 19
I am having two WAR Files. The first one contains a javascript and some utility functions along with the View Layer JSP. Second one contains user interfaces. Both the WAR files are there in the same server.

I need to access the utility functions and javascript from the second WAR. I am not sure, how to do this.

I cannot add the first WAR as a project reference in the second WAR and put it as a single WAR, as these two needs to be separately deployed.

Can I use context path and access the Java Utility functions? is it possible to use the same method for getting the Javascript functions?

Can anyone suggest any method to access the Javascript functions?

I am not sure, whether this question is relevant in this thread. I have posted it here, as i am using a JSP and servlet.

Thanks,
Baranidharan
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41532
    
  53
A web app can't access Java code in another web app.

JavaScript files generally reside in public directories, so it's possible to reference them using an "http://..." URL. I wouldn't recommend that, though. It's too easy to create problems later if you want to restructure the files/directories of the web app. Why not include the JavaScript files in both web apps? If you want only a single copy of the file, you can structure your source code repository in a way that both web apps get the file from a single location in it.


Ping & DNS - my free Android networking tools app
Baranidharan Ramakoti
Greenhorn

Joined: Aug 14, 2007
Posts: 19
Thanks Ulf for your instant reply.
Baranidharan Ramakoti
Greenhorn

Joined: Aug 14, 2007
Posts: 19
What is the use of communicating between two WARs? I have seen one of the Threads regarding this in Javaranch and had found that communication can be done in many ways.

If the utility Java functions inside WAR and other files cannot be accessed, then what is the reason for setting dependencies between two WARs?

Can someone just throw some light on these questions?

Thanks,
Baranidharan Ramakoti
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Need to refer a Javascript from another WAR file