Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Splitting out static content in JSF application  RSS feed

 
evan k. stone
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK... here's the scenario.

I'm developing a JSF application running under JBoss, and I�d like to have two .WARs sitting in a sever in JBoss (we�ll call it �foo� for originality�s sake), the first one would be exploded for conveniently working with static content (css/images/javascript/etc.), the second one would be archived containing the dynamic content (JSPs and the like), sort of like the following:

\jboss\server\foo\deploy\static.war
\jboss\server\foo\deploy\dynamic.war

�and I�d like to be able to pull the static content from pages in the dynamic war. For some reason, however, it�s not working the way I expected, and images/css are not being found. After pulling out the static content, the JSF application works, but of course it looks atrocious since it seems not to be able to locate the static content.

So is there some configuration that has to be performed with the server to get it to point to content in the other WAR, and do my URLs that point to images/css/javascript have to be formed in a special way for the server to serve up the items?

I know next-to-nothing about configuring jboss/tomcat/apache, but I figure there must be some way to get this to work.

Any information you can supply to help me in the right direction will be greatly appreciated.

Thanks in Advance!
 
Andres Quinones
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by evan k. stone:
OK... here's the scenario.

I'm developing a JSF application running under JBoss, and I�d like to have two .WARs sitting in a sever in JBoss (we�ll call it �foo� for originality�s sake), the first one would be exploded for conveniently working with static content (css/images/javascript/etc.), the second one would be archived containing the dynamic content (JSPs and the like), sort of like the following:

\jboss\server\foo\deploy\static.war
\jboss\server\foo\deploy\dynamic.war

�and I�d like to be able to pull the static content from pages in the dynamic war. For some reason, however, it�s not working the way I expected, and images/css are not being found. After pulling out the static content, the JSF application works, but of course it looks atrocious since it seems not to be able to locate the static content.

So is there some configuration that has to be performed with the server to get it to point to content in the other WAR, and do my URLs that point to images/css/javascript have to be formed in a special way for the server to serve up the items?

I know next-to-nothing about configuring jboss/tomcat/apache, but I figure there must be some way to get this to work.

Any information you can supply to help me in the right direction will be greatly appreciated.

Thanks in Advance!


Evan what I know is that you need to have your images/css/javascript in the same war to make refence to it. So I don�t think it�s possible to have this in separate war files.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's nothing unique to JBoss here. A J2EE WAR is a unit of deployment. Within that unit are definitions that bind the components of that unit together.

When a WAR is deployed, an application context is created and bound to it. It is both possible and occasionally useful for the same WAR to be instantiated multiple times using multiple contexts just as you instantiate a class multiple times.

Each web application context has its own unique base URL. This base URL is what's used by the application container - be it Tomcat, JBoss, WebSphere or whatever - to route HTTP requests to that context as opposed to any of the other contexts in the server instance.

There's no law that says that everything on a web page has to come from a single webapp or a single WAR. A typical web page is actually made up of multiple HTTP URL requests as its components are retrieved and assembled by the client. Some common examples are placing static content under the control of an Apache server instead of having it come from the J2EE app or having things like page hit counters and popup ads come from some other vendor entirely off a server on the other side of the planet.

The key is the URL. If you want webapp A to be able to serve images stored in Webapp B's WAR, you have to code them in terms of webapp B's URL context so the appserver will know where to retrieve them.

Too many people see the slashes in a URL and mistakenly think that they're making file requests. To be a true master of the web, you have to realize that a URL is not a file path - it's a resource locator, and the web app designer can resolve those resources in any number of ways.
 
J Haley
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the following tag may also help. You can use this to change your base url.

<base href=""/>

[ February 15, 2007: Message edited by: J Haley ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!