This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I map the root of servlet and send down a static page

 
ken carlino
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
ken carlino
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please post web.xml file? do you have any welcome page setting?
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never used that library before, but after glancing at the doc, maybe this would work:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic