Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet mapping

 
Ed Carrington
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a page url like this:
http://servername:8080/test/Data?abc=2&cwe=n

Data is a servlet.

Anyway to map this in web.xml so I can change the name to:
http://servername:8080/test/mynewname

This didnt work:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ummm, why do you have a query string on the servlet name?
 
Raghu ram
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This didnt work:

code:
--------------------------------------------------------------------------------

<servlet>
<servlet-name>DataMatch</servlet-name> <-- 1
<servlet-class>Data</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DataMatch</servlet-name> <-- 2
<url-pattern>/mynewname</url-pattern>
</servlet-mapping>

Name of servlet class not be same as name of servlet name and the lines 1 and 2 should be same.
 
Ed Carrington
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ummm, why do you have a query string on the servlet name?


The Data servlet actually has a request dispatcher that forwards the info with parameters from the servlet to a JSP. The url though shows as a servlet even though I am presenting the info on a JSP. I assume the request dispatcher is doing that where it keeps the servlet name in the url even though I am forwarding and showing a JSP?
[ December 12, 2007: Message edited by: Ed Carrington ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but why do you have a query string on the servlet name?
 
Ed Carrington
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assumed my Servlet took the query parameters that was stored in the Servlet and passed them as a query string into the JSP url and I thought that was normal. Be back tomorrow to give you more details when I get access to it in the morning.
[ December 12, 2007: Message edited by: Ed Carrington ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you cannot specify a query string in the mapping.

The way that you pass data from a servlet to a forwarded JSP is via scoped variables, usually placed on the request.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic