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 Web Application without a Context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Web Application without a Context" Watch "Web Application without a Context" New topic
Author

Web Application without a Context

Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
So I was handed some rather old code the other day because after a server migration, the folks handling this code found that it no longer worked and they had no one around that could support it. I told them that I'd look at it and see if I could figure out what was wrong.

It's a J2EE web application but, what I find puzzling, is that it runs (or ran, I should say) without a context. By that, I mean that you did this to access the application:

http://www.server.com/servlet/controller

Within the web.xml is this:



There's no servlet-mapping element - it appears that this accesses the servlet directly. Unfortunately, this mapping appears elsewhere in the application so I can't just change it in one place and be done with it - even worse, this path appears in an old .swf file for which there is no corresponding .fla to modify. As such, I think my only hope to fix this without doing any major changes is to figure out how this "accessing a servlet directly" thing works. Unfortunately, me Google searches have come up empty.

Anyone have any knowledge or any good references I could be pointed to?

Thanks,
Corey


SCJP Tipline, etc.
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
Not sure what app server you use and the Java EE spec is used. While changing the URL for this servlet, I would suggest to create a forward/redirect from the old location so that old references keep on working.


My Blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

The app is probably using the dreaded Invoker. See: http://faq.javaranch.com/view?InvokerServlet


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

P.S. "Context" is the wrong word. Every web app has a context. I think you meant "mapping".
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Thanks, Bear.

You're right on both counts - this old application was using the Invoker Servlet to get things done and "mapping" would have been a much better word to use. I believe I now have it fixed up.

One thing to note - in that article you referenced, there were a couple things that are no longer accurate, particularly when dealing with Tomcat.

1. In addition to the mapping that must be uncommented to use the InvokerServlet, you must also uncomment the actual servlet:



In my installation (Tomcat 6.0.18), both were commented out.

2. Once uncommented, the InvokerServlet still did not start properly on my installation. In addition to uncommenting these sections, I also had to add 'privileged="true"' to the Context element in the conf/context.xml file.

As soon as I made those changes, I was able to get it working. Fortunately, there were not that many places that used the InvokerServlet path so not many changes were required to get the application off of that and working.

Thanks again, Bear.

- Corey
[ October 04, 2008: Message edited by: Corey McGlone ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Application without a Context