Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where to look for the error...

 
trupti nigam
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying some sample examples from marty halls "more servlets and java server pages book.."
So I think the code is 100% correct..
but still I am not able to see the desired result.
The code is as follows..SetSharedInfo.java
package myServlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class SetSharedInfo extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
HttpSession session = request.getSession(true);
session.setAttribute("sessionTest","Session Entry one");
ServletContext context = getServletContext();
context.setAttribute("servletContextTest","Servlet context entry one");
Cookie c1=new Cookie("cookieTest1","Cookie One");
c1.setMaxAge(3600);
response.addCookie(c1);
Cookie c2 = new Cookie("cookieTest2","Cookie two");
c2.setMaxAge(3600);
c2.setPath("/");
response.addCookie(c2);
String url = request.getContextPath()+"/servlet/myServlets.ShowSharedInfo";
url = response.encodeRedirectURL(url);
response.sendRedirect(url);
}

}//--class

when I try to access this servlet i get the following error..
The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
javax.servlet.ServletException:
Cannot allocate servlet instance for path /myDevelopment/servlet/myServlets.SetSharedInfo
Root cause:
java.lang.NoClassDefFoundError: myServlets/SetSharedInfo (wrong name: mySerlets/SetSharedInfo)
where shoul I look for the wrong name "mySerlets/SetSharedInfo"
I have checked the directory name and they are spelled correctly.
thanks in advance..
Trupti
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlets name is 'SetSharedInfo' but the URL is calling 'ShowSharedInfo' - try to change one of them.

Rene
[ October 11, 2002: Message edited by: Rene Larsen ]
 
trupti nigam
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for not giving the whole scenario..
the SetSharedInfo.java inernally calls the ShowSharedInfo.java
If I try to access this servlet it gives me NullPointer exception.
thanks..
Trupti
 
Nikki Aniban
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... maybe you mistyped the url-pattern in the servlet-mapping tag of your web.xml? Anyway, if you really get desperate, you can use the ever reliable "Find Files and Folders" function of your OS to search for the phrase "mySerlets/SetSharedInfo" in your entire computer! Let's see if this doesn't solve your problem.
Hope this helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic