Can two urls map to same servlet in web.xml

Hello All,
I need to map the two urls in my web application with the same servlet.
I tried as follows:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee">
<description>Empty web.xml file for Web Application</description>
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>fileredirectsolution.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/testservlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/filerepository/*</url-pattern>
</servlet-mapping>
</web-app>
However, I am getting an error while accessing the TestServlet.
When I remove the second servlet-mapping tag..it is working fine.
How can I map the two urls with the same servlet.
Thanks
Saikrishna

it is not ur requirement. but
i think it will help 2 u.
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4"; xmlns="http://java.sun.com/xml/ns/j2ee">
<description>Empty web.xml file for Web Application</description>
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>fileredirectsolution.TestServlet<;/servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>*.xxx</url-pattern>
</servlet-mapping>
</web-app>
if ur configure web.xml like above.
any request that ends with .xxx call the TestServlet.
ex:
1)http://ip:port/contextpath/abc.xxx
2) http://ip:port/contextpath/xyz.xxx
here both urls calls the same servlet.
-lakshman.
save a life by sending information.
www.help2patients.wordpress.com.

Similar Messages

  • Can two people share the same Apple ID on two different iPhones and maintain different passwords?  Yes, there is more to the story.

    I have an iMac, and iPhone.  I've had my Apple ID for a few years. 
    My wife got an iPhone 4S a few months back and the salesperson at Verizon set her Apple ID the same as mine, but gave her a different password.  I don't know if this was ok, but that is what happened.
    So, yesterday, we both upgraded to IOS6 and I had no problem logging in to my iPhone with my Apple ID.  When my wife went to log in, she was told that she was entering the wrong password. We entered the password over and over again and still was wrong.
    The question is... can two people share the same Apple ID on two different iPhones and maintain different passwords?  (I have the feeling her iPhone is thinking that since it's my Apple ID, it wants my password.)
    If not, can I still set up a new Apple ID for her even through she's had the iPhone for a few months?
    Thanks.

    Hi
    You shold follow your feelings, its probably right most of the time.
    You can have 5 different devices hucked upp to one Apple ID. What I have done is that my wife and I have one Apple ID, when I bye a new app on my phone, She gets it to. Thats nice.
    You can allways set upp a new Apple ID for your wife.

  • Can two users on the same Mac sync contacts by using the same Apple ID in the iCloud settings?

    Can two users on the same Mac sync contacts by using the same Apple ID in the iCloud settings?

    Hi Barney,
    That's exactly what I want. I have a personal user and a business user on my MacBook Pro. I want both users to have the same contacts so if I add a contact while I'm logged into my personal user, it will show up when I'm logged into my business user. I want both contacts books to be exactly the same; like you said. So, I used my business user AppleID when I enabled iCloud for my personal user and I enabled iCloud for my business user with that Apple ID as well. For my personal user, I selected Contacts and Calendars to sync with iCloud. For my business user, I selected everything to sync with iCloud. The problem is... it didn't change anything. I restarted my computer to see if that would do anything but nothing happened. I'm not super savvy with Apple products, so maybe I'm completely confused.
    Hi Xeni,
    Thank you for your response, as well.
    KEW

  • HT5177 How can two people edit the same FCPX file? One company, so both people/computers share the same license. Example: I work on revision A and my boss takes it and makes revision B and gives it back to me using two separate computers.

    How can two people edit the same FCPX file? One company, so both people/computers share the same license. Example: I work on revision A and my boss takes it and makes revision B and gives it back to me using two separate computers.

    Have the project, events and media on one drive which is common to both macs.
    You can download FCP X to both macs using the same Apple ID that it was purchased with.
    Andy

  • HT204053 can two devices share the same apple id

    can two devices share the same apple id

    Yes.
    According to this Support Article  >  http://support.apple.com/kb/HT4627
    Your Apple ID can have up to 10 devices and computers (combined) associated with it.

  • HT1495 Can two people use the same itunes account?

    Can two people use the same iTunes account? On different computers and different devices?

    Yes, READ the article from which the question was posted as it explains how to do so in detail.

  • Can two bands use the same name on iTunes?

    Hi, I'm in a band that uses the same name as another band listed on iTunes.
    Can two bands with the same name be listed on iTunes? We hope to eventually have an album for sale on the site and I'd like to know now if it's going to be a problem.

    Of course it will be a problem. You simply can not have two bands with the same name. I can think of MANY bands that had to change their names (either completely or just for certain countries) because the name was already taken. Blink (Blink-182), Bush (Bush X), The Beat (The English Beat), Yazoo (Yaz), and the list goes on and on.
    Your band better start brain storming for a new or modified name.
    Patrick

  • Can two players use the same game app without erasing each other's scores?

    Can two players use the same game app on the same device without erasing each other's scores?  My two sons build up their characters and progress in their games, then the other one wants to play, erasing the first son's progress.
    Is it possible to create two player identities in the Game Center? 
    Is it possible to have two different Apple User ID accounts on the same device?  Is that even desirable?
    Many thanks!
    MCPROBW

    You can create as many individual user accounts on a Mac as you like. Then, any one or more of those users can remotely log in from another Mac and use that Mac as their own, simultaneously. Each account will remain separate from all others.
    However, since each user needs to have a Mac to do that, I'm not sure how you could effectively double the number of users as you describe.

  • Can two ipods with the same email address face time independantly?

    Can two ipods with the same email address face time independantly?

    Hey Bumblebee, To each other, no-- would be like trying to call yourself on the same phone. To different persons on other devices??? Not sure you'll have to try, I'm guessing if both are online you may well dial up on both, (once had the same address on the my computer and iPod, both would ring when called, this stopped when I changed the iPod's address). If you change one of the iPod's e-mail address you should be fine. You'll have to do a little experimenting. Hope this helps, Good luck. Cheers.

  • Can two Iphones have the same account/email address?

    Can two iphones have the same account/email address? I bought two phones-one for my wife and the other for myself. They are both under the same account /itunes account /email address-Would this cause a conflict with the two phones?

    No, as long as you want to share the same account for iCloud's services like Mail, Calendars, Contacts, Reminders, Notes, iCloud, Documents etc.
    I personally would create two accounts so that everyone could have and use  heir own mail account, address book, create meetings, reminders etc. without reading and deleting stuff of the other person.

  • TS3899 Can two people have the same email address and password on their phone?

    Can two people have the same email address and password on their phone?

    I guess so.    But the email content will mirror on both phones.
    If you are talking about your Apple ID and iCloud email, yes, it is possible, but again the phones will mirror.   You should not have the same Apple ID and iCloud both.  
    Why?
    If you explain the reason for the question we may have a solution that works for you.

  • How to set two different welcome-file to different servlets in web.xml

    Hi friends,
    Can some one help with web.xml file
    I have to different servlets in applications.
    I want to set two different welcome files for my two different
    servlets in web.xml
    Please, can some one give me sample code to achieve this.
    Here web.xml code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>     
         <servlet>
              <servlet-name>reports</servlet-name>
              <servlet-class>com.caremark.ivr.servlet.IvrReportsServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>reports</servlet-name>
              <url-pattern>/reports</url-pattern>
         </servlet-mapping>
         <session-config>
              <session-timeout>30</session-timeout>
         </session-config>
         <welcome-file-list>
              <welcome-file>reportsindex.jsp</welcome-file>
         </welcome-file-list>
         <servlet>
              <servlet-name>calldetails</servlet-name>
              <servlet-class>com.caremark.ivr.servlet.IvrCallDetailsServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>calldetails</servlet-name>
              <url-pattern>/calldetails</url-pattern>
         </servlet-mapping>
    <welcome-file-list>
              <welcome-file>calldetailsindex.jsp</welcome-file>
         </welcome-file-list>
    </web-app>
    I need this fix immediately. Your help will be really appreciated. Thanks in advance.

    First of all, my understanding is that you need to have a Servlet 2.4 complaint server to do this...Given that, you're supposed to be able to simply specify the Name of the servlet as the welcome-file to get it to work. For example:
    Your servlet section:
    <servlet>
      <servlet-name>Controller</servlet-name>
      <servlet-class>com.company.ControllerServlet</servlet-class>
    </servlet>Now you would add the following to your welcome file list:
    <welcome-file-list>
      <welcome-file>Controller</welcome-file>
    </welcome-file-list>Note that you use the servlet-name value from the servlet definition, NOT the url-mapping from the servlet-mapping section.
    Please note that I cannot verify this as I am running a 2.3 server at home. When I get to work Friday I can test on a 2.4 machine. However this shouldn't take you more than a minute to test.
    Note that I did try this on the 2.3 compliant server and it did NOT work (as I expected)...
    HTH.

  • Eclipse, WTP, Servlets and Web.xml

    I wonder if you could help me.
    I am using Eclipse and Web Tools Platform.
    In eclipse, when I create a Servlet, I believe the servlet details (such as name, class, url-pattern) should be included into web.xml file automatically. However, this is not happening.
    Would you know how I can configure Eclipse and WTP to automatically write Servlets details into web.xml files.
    Thanls

    Thanks for the reply
    I have Eclipse 3.2 and WTP 1.5
    Yes, I am creating my Servlet in a project under the Dynamic Web Projects.
    I deploy my WAR file using the 'Export' menu.
    Now, I have manually added the servlet details into the web.xml file:
    <servlet>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>com.mycom.HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>/HelloWorld</url-pattern>
    </servlet-mapping>
    I am accessing the servlet as:
    http://localhost:9090/MyFirstServlet/HelloWorld
    But I still get HTTP 404 error when accessign HelloWorld servlet. I am not sure what I am missing.
    Thanks

  • MUST I include every servlet in web.xml??

    I am learning servlet and trying to write some codes by myself.
    When I want to invoke servlet by form, tomcat always shows that the requested resource is not available.
    I've tried some different paths for the value of ACTION, but none of them work.
    Hence, I'm wondering whether I can invoke a servlet in form without explicitly write it in web.xml??
    Could anyone generously give me an answer?

    It may be possible to configure your web server so it executes servlets with URLs like http://the.ser.ver/servlet/com.yourcompany.yourpackage.TheServlet. URLs like that are ugly and can lead to security problems so I definitely recommend against them.
    You could write a front controller servlet. Then you'll need to configure the servlets in YourFrontControllerServletConfig.xml instead of web.xml so I'm not sure if that buys you much.
    I'd just configure servlets in web.xml. That's what it is there for.
    When you write a servlet you gather requirement specs for your servlet, do architecture and technical design, graphic layout design, servlet programming, back end code programming, unit testing, jar deployment, system (& performance, security, usability, etc) testing. After all that, the task of copy&pasting ten lines in web.xml shouldn't be a terribly large task. Unless you have lost nine of your fingers in a horrible chain saw accident or something.
    (Apologies to anyone out there who has lost nine of his fingers in a terrible chain saw accident.)

  • Different url-patterns for same servlet running in 2 different environments

    Hi All,
    I have a question about url mappings in my web.xml file and I hope somebody can help. The situation is that I�m putting together a web app using a combination of JSPs and servlets. I can�t develop on the machine that it will be hosted on, so I�m working and testing on my own machine and will transfer to the host machine when finished. However, the host machine is set up to map serlvets to http://�/servlet/MyServlet but the copy of tomcat I have installed locally maps to http://�/MySerlvet. My question is, when I get ready to transfer my application do I have to go through all my code and find serlvet references and insert the �servlet/� path info required by the hosting service, or can I just change the url patterns for the servlet mappings of the web.xml file on the host machine ? In other words:
    Local install of Tomcat where servlets are accessed at http://�/MyServlet
    <servlet-mapping>
    <servlet-name> MyServlet </servlet-name>
    <url-pattern>/MyServlet </url-pattern>
    </servlet-mapping>
    Host machine install of Tomcat where servlets are accessed at http://�/servlet/MyServlet
    <servlet-mapping>
    <servlet-name> MyServlet </servlet-name>
    <url-pattern>/servlet/MyServlet </url-pattern>
    </servlet-mapping>
    I guess my thinking is that it would be better/easier to have a remote and local version of the web.xml file that reflects the environment each one resides in and have only one codebase rather than 2 codebases and 1 web.xml file. Am I thinking about this in the right way, or have I misunderstood something?
    Thanks,
    Peter

    What you�re suggesting is logical, but won�t that
    effect all the other stuff I�ve got running on my
    local Tomcat install that expects servlets to be
    accessed at http://.../ServletName ?
    in web.xml, you decide of your mapping, so you could use the /servlet/ServletName pattern for your application that needs to be remote, and /ServletName for the rest of your stuff. You can even define more than one mapping for a servlet...
    In fact, you should probably put your whole application that is going to be on a remote server in it's own context, and to be ahead of dufymo :-) , learn to put it a war file for deployment.

Maybe you are looking for

  • IPhoto crashing when trying to delete photos

    I have about 122,000 photos in my trash folder within iphoto.  I know, I know, I shouldn't have that many.  Actually I didn't know that they were being collected in my trash folder when I deleted photos in iphoto. Now the problem I am having is that

  • Shell script for calling an sql file

    Hello, I would need your help in creating a ksh file. We have two ksh files. One for deletion the eim table and the other one is for running the eim job. Ksh file for running the eim job is okay. But the ksh file running the delete sql is not. We wer

  • Simple Error In a Test

    Hello, I am trying to do a simple Class.forName() to see if I have my driver string in-line. It is test code and looks like this: import java.sql.*; public class TestDB { public static void main(String[] args) { try { Class.forName("oracle.jdbc.drive

  • Non stock material info record

    Hi SAPERS, Please let me know the difference between the stock material and non stock material info records, Is there any difference in creation of both records. Thanks in Advance, D Prasad

  • New Layer Via Copy from Extension

    Hello everybody, I'm trying to create a new layer using the Layer > New > Layer Via Copy functionality... and I did scan the code using the Scripting Plug-in with this result: var idCpTL = charIDToTypeID( "CpTL" ); executeAction( idCpTL, undefined, D