Results 1 to 3 of 3
  1. #1
    Mega Man X is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default Servlet Mapping question.

    Hi everybody :)

    This is my first post here, so I apologize in advance for anything I probably will do :p

    I need help with a servlet mapping issue. I've created a servlet. The URL to the servlet looks like this:

    http://localhost/ec/mail?id=523/8PysK6GF034

    "mail" is the servlet, with takes one parameter, id, which I retrieve later with:

    req.getParameter("id")

    That works fine, no problems there. The slash "523/8PysK6GF034" is just a commodity I have to help me "split" the above string later, inside my servlet.

    Again, all this work. However, I want to part the above like this:

    http://localhost/ec/mail/523/8PysK6GF034

    That means, I want to, somehow, get the string being parsed after the servlet. (523/8PysK6GF034)

    How can I do that? My web.xml looks like this (the relevant parts):

    Java Code:
    <servlet>
        <servlet-name>WebMailServlet</servlet-name>
        <servlet-class>xx.xx.xx.xx.WebMailServlet</servlet-class>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>WebMailServlet</servlet-name>
        <url-pattern>/mail/*</url-pattern>
    </servlet-mapping>
    The server I use is JBoss, if that is worthy mentioning :)

    Thanks in advance.

    X

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,036
    Rep Power
    20

    Default

    Does that mapping get to your servlet then?
    If so, what do you have at the moment to try and extract that suffix?

  3. #3
    Mega Man X is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default Thanks Tolls

    I was here trying to find a way to fix this, and I've managed it. All I had to do was to use req.getPathInfo(). That did the trick. Then, with:

    Java Code:
    String[] temp = req.getPathInfo().split("/");
    String message_id =temp[1];
    String access_password = temp[2];
    And I had all I needed. It is important to notice that the url-pattern:

    Java Code:
    <servlet-mapping>
        <servlet-name>WebMailServlet</servlet-name>
        <url-pattern>[B]/mail/*[/B]</url-pattern>
    </servlet-mapping>
    made it possible here ;)

Similar Threads

  1. Servlet mapping
    By cozsmin in forum Java Servlet
    Replies: 1
    Last Post: 04-04-2009, 09:15 AM
  2. Question regarding url-pattern in Servlet
    By basark in forum Java Servlet
    Replies: 1
    Last Post: 09-06-2008, 01:05 PM
  3. Servlet Question
    By sandor in forum Java Servlet
    Replies: 5
    Last Post: 12-19-2007, 11:27 AM
  4. About servlet-mapping
    By Heather in forum Java Servlet
    Replies: 1
    Last Post: 07-14-2007, 06:00 PM
  5. Servlet question
    By Peter in forum Java Servlet
    Replies: 2
    Last Post: 07-04-2007, 01:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •