• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to refer a Javascript from another WAR file

 
Baranidharan Ramakoti
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Baranidharan Ramakoti
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf for your instant reply.
 
Baranidharan Ramakoti
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic