This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I think I read in Sun spec that the context root has to start with '/' and end with string.
This is what I'm trying to do and maybe some other suggestions can be made.
I have a tookit (RAD 6.0).
The code base has image references to /flash, /images, etc. On the server environment there is an HTTP server and an plugin-cfg that will be able to serve those images,
however on my toolkit (IDE), I don't have the luxury to install an IHS and setup a plugin config ( I can put its the effort I"m trying to avoid).
So what I did was create a servlet with a context root of "/flash" and I have flash content in that Web App.
This works great,
but now i have /images reference, as well. However, I don't want to create another servlet for that.
So I was thinking of this approach.
Have the context root "/" so that when the request in the code is something like <img src="/images/1/blah.jpg"/>
it will know to go to my servlet, and then serve the image.
However, I'm getting errors.
So what I was thinking was to use URLRewrite servlet and then rewrite /flash to another servlet or another location.
However, this is all predicated on using context root as "/" only.
Basically I need to host images /images/...
and I'm not sure if this is possible without installing a webserver.
Hi Bear -
Sure let me start from the top.
We have development environment. This has RAD 6.0 as the IDE. and a websphere test server configured.
We have an EAR and WArs as part of our project setup.
Now when we start the server and hit the url http://localhost/online/sale/index.jsp Our page doesn't render completely, (flash, images) are missing.
This is because the creative team directly puts static content on the web server(its not part of the WAR).
So in the index.jsp has <img src="/images/logo.jpg"/> which will say webgroup/virtual host not setup in toolkit console.
There is a suggestion of installing a webserver,and using the plugin-cfg.xml but I'm trying to avoid that since our dev toolkit is in a vm.
So what I would like to do is be able to have our toolkit test server be able to recognize /images/.. and host it.
and there is a /flash folder as well.
You should be able to define a web application which serves as the "root" or "default" web application.
For sure you can do it in Tomcat - you define the context root as "" (empty string)
I'm not sure if/how you can do it in WebSphere, but try setting a context root of empty string or, /
See if you have an already existing one (access your server via the browser to see if anything comes up)
If you CAN specify the default/root web application then you just need to stick your /images and /flash directories there and it should act pretty much the same as the one with a webserver in front.
Joined: Feb 18, 2011
Hi Stefan -
Thank you for your reply.
I read its possible with Tomcat.
Also, I'm doing this via RAD 6.0; which is the IDE, that I'm trying to get this context root to work.
What I did do is this. in the dynamic web project; I made it "/" only (It would not allow for empty).
When I do this. it seems to be going in an infinite loop.
What I plan on doing next is to make the context root "/" and then create a URL mapping to hit the servlet.
The servlet I have created gets the path and creates a requestDispatcher and forwards the request to that. If you would like I can post the code.
but it seems to work when I have a context root defined and and url mapping.
I'll keep you posted on what happens when I try this out.
If you have any other suggestions please let me know.
Do you know for Tomcat the default application is using a servlet, or is it just a dummy servlet?