• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need to refer a Javascript from another WAR file

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf for your instant reply.
 
Baranidharan Ramakoti
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Their achilles heel is the noogie! Give them noogies tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic