facebook

Unable to run Servlet program in websphere 6.1

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #324853 Reply

    hem_kec
    Participant

    Hi,
    I am trying to deploy my servlet proggram in websphere 6.1.
    I always get the following error while opening http://localhost:9080/WebListener
    “The webpage cannot be found”

    Many time i face problem while deployment.

    MyEclipese: Version: 9.1 Blue Build id: 9.1-Blue-20110701
    WebSphere: 6.1

    Following is the code which i want to test.

    
    Dog Class:
    
    package Lstnr;
    
    public class Dog
    {
        private String breed;
    
        public Dog( String breed )
        {
            this.breed = breed;
        }
    
        public String getBreed()
        {
            return breed;
        }
    }
    
    ListenerTester:
    
    package Lstnr;
    
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    
    public class ListenerTester
        extends HttpServlet
    {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
    
        public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("test context attributes set by listener<br>"); out.println("<br>");
    Dog dog = (Dog) getServletContext().getAttribute("dog");
    out.println("Dog’s breed is: " + dog.getBreed());
    }
    }
    
    MyServletContextListener class:
    
    package Lstnr;
    
    import javax.servlet.ServletContext;
    import javax.servlet.ServletContextEvent;
    import javax.servlet.ServletContextListener;
    
    public class MyServletContextListener
        implements ServletContextListener
    {
        public void contextInitialized(ServletContextEvent event) {
        ServletContext sc = event.getServletContext();
        String dogBreed = sc.getInitParameter("breed");
        Dog d = new Dog(dogBreed);
        sc.setAttribute("dog", d);
        }
    
        public void contextDestroyed( ServletContextEvent event )
        {
            // nothing to do here
        }
    
    
    
    
    }
    
    web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    
    
        <servlet>
            <servlet-name>ListenerTester</servlet-name>
            <servlet-class>Lstnr.ListenerTester</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>ListenerTester</servlet-name>
            <url-pattern>/ListenTest.do</url-pattern>
        </servlet-mapping>
        <context-param>
            <param-name>breed</param-name>
            <param-value>Great Dane</param-value>
        </context-param>
        <listener>
            <listener-class>Lstnr.MyServletContextListener</listener-class>
        </listener>
    </web-app>
    

    Please suggest what is wrong in my setup.

    Regards
    Hemant.

    #324869 Reply

    support-swapna
    Moderator

    Hemant,

    Sorry that you are seeing this issue.

    1. Can you send us the deployment log, to help us investigate further ?

    2. Please take a look at these links which explain deployment of servlets in Websphere :

    http://fixunix.com/websphere/558722-how-deploy-servlet-websphere-6-0-a.html
    http://en.allexperts.com/q/JSP-Java-Server-3299/Deploying-Servlets-Websphere-v6.htm

    If you are looking for information on how to deploy a servlet to Websphere, then please cross post to Websphere support forums for better support.

    Hope this helps.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Unable to run Servlet program in websphere 6.1

You must be logged in to post in the forum log in