MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
hem_kec
Post subject: Unable to run Servlet program in websphere 6.1  PostPosted: Mar 31, 2012 - 04:31 PM



Joined: Feb 18, 2012
Posts: 6

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.

Code:

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.
 
 View user's profile Send private message  
Reply with quote Back to top
support-swapna
Post subject:   PostPosted: Apr 02, 2012 - 09:40 AM



Joined: Nov 11, 2010
Posts: 2490

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.

_________________
Swapna
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits