• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet mapping

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ummm, why do you have a query string on the servlet name?
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic