| Author |
How can I map the root of servlet and send down a static page
|
ken carlino
Greenhorn
Joined: Nov 06, 2006
Posts: 10
|
|
Hi, I have a servlet which map to the root url, like this, But in the doGet() of my TestServlet, if i do this: it will keep recursively calls back to the doGet() of my TestServlet. Can you please tell me if there is a solution to my problem? i.e map my servlet to the root and yet I am able to send down static page ? Thank you.
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12325
|
|
Can you please tell me if there is a solution to my problem?
You are going to have to rethink the nature of your problem. Normally requests like /index.html are handled by the "default" servlet as defined in the base web.xml. You have defined your servlet as a replacement for the default servlet so it gets all "/" requests. What exactly are you trying to accomplish? Bill
|
Java Resources at www.wbrogden.com
|
 |
ken carlino
Greenhorn
Joined: Nov 06, 2006
Posts: 10
|
|
Thanks. Here is what I want to accomplish: My webapp context name is "testApp". If user hits 'http://localhost:8080/testApp/?lang=en', return '/index.html' If user hits 'http://localhost:8080/testApp/?lang=jp', return '/index_jp.html' If user hits 'http://localhost:8080/testApp/TestServlet1?lang=jp', invoke TestServlet1 with the query string. Thank for any idea.
|
 |
gopinathang nathan
Ranch Hand
Joined: Oct 28, 2006
Posts: 41
|
|
|
can you please post web.xml file? do you have any welcome page setting?
|
 |
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
|
|
You don't mention which web server you are using (if any), but you could have the web server rewrite the url: /testApp/?lang=jp would become: /testApp/index_jp.html [ November 11, 2006: Message edited by: Scott Johnson ]
|
 |
ken carlino
Greenhorn
Joined: Nov 06, 2006
Posts: 10
|
|
Thanks. I am using Tomcat and I try to use the UrlRewriteFilter http://tuckey.org/urlrewrite/ project I add this rule: <rule> <from>/?lang=jp</from> <to type="redirect">%{context-path}/index_jp.html</to> </rule> Butt this does not work, I will be redirect to whenever I hit 'http://localhost:8080/testWebApp/?lang=jp' http://127.0.0.1:8080/?/testWebApp/rewrite-status
|
 |
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
|
|
I've never used that library before, but after glancing at the doc, maybe this would work:
|
 |
 |
|
|
subject: How can I map the root of servlet and send down a static page
|
|
|