This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Web Application without a Context

 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vinod K Singh
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The app is probably using the dreaded Invoker. See: http://faq.javaranch.com/view?InvokerServlet
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. "Context" is the wrong word. Every web app has a context. I think you meant "mapping".
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic