Results 1 to 4 of 4
  1. #1
    CapsLoc is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default java packages and (web)applications

    Hello,

    I am very new to the java programming language, java servlets is perhaps even more confusing to me. So I'm hoping my explanation will make some sense.

    I have set up a server through Terminal (/Command Prompt), more specifically the Mobicents Sip Server. And to test this server Mobicents provided a sample application 'click-to-call' (which can be accessed through localhost:8080/click2call/ when the server has been started). The WEB-INF directory of this directory contained four java classes, two of which are called SimpleWebServlet and SimpleSipServlet (the code can be found here: http://www.google.com/codesearch#NmC...s_navigation=1).

    I am a bit confused how these classes are being used upon running the (web)application, as they are part of a package.

    Also, does the SimpleWebServlet correspond to the web application and the SimpleSipServlet to the (SIP) server I started? Or what is the appropriate way I should address these two classes?

    Thanks in advance.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,863
    Rep Power
    19

    Default Re: java packages and (web)applications

    Is there a web.xml file in the WEB-INF directory?
    This is where the mapping of the servlet to a URL is done, so the server knows that click2call/SimpleWeb maps to SimpleWebServlet, for example.

  3. #3
    CapsLoc is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default Re: java packages and (web)applications

    Hello,

    thank you for your reply.

    Indeed, there is a web.xml file:

    XML Code:
    <?xml version="1.0" encoding="iso-8859-1" ?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" 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">
        <display-name>Click To Call</display-name>
        <description>Simple Converged Sip Servlet Demo</description>
        <servlet>
            <servlet-name>ClickToCall</servlet-name>
            <servlet-class>org.mobicents.servlet.sip.example.SimpleWebServlet</servlet-class>
            <load-on-startup>1</load-on-startup>        
        </servlet>
        <servlet-mapping>
            <servlet-name>ClickToCall</servlet-name>
            <url-pattern>/call</url-pattern>
        </servlet-mapping>
    </web-app>
    so it's the part between <servlet-class> that informs the server it should deploy the simplewebservlet when visiting the url? Or is it related to the <url-pattern>?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,863
    Rep Power
    19

    Default Re: java packages and (web)applications

    The url-pattern maps the url to a servlet-name.
    The servlet-name maps the name to an actual class.
    So it needs both to go from the url to your actual class.

Similar Threads

  1. using SSL in java applications
    By porchrat in forum Advanced Java
    Replies: 4
    Last Post: 06-28-2011, 01:15 PM
  2. Java Packages
    By ShitalJain in forum New To Java
    Replies: 12
    Last Post: 06-11-2011, 08:14 AM
  3. Replies: 3
    Last Post: 02-12-2008, 11:03 AM
  4. JDOM in java applications
    By boy22 in forum Advanced Java
    Replies: 1
    Last Post: 08-02-2007, 05:38 PM
  5. convert VB6 applications to Java
    By bbq in forum New To Java
    Replies: 1
    Last Post: 07-05-2007, 03:57 AM

Posting Permissions

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