This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes where to look for the error... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "where to look for the error..." Watch "where to look for the error..." New topic

where to look for the error...

trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 614
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
package myServlets;
import javax.servlet.*;
import javax.servlet.http.*;

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");
Cookie c2 = new Cookie("cookieTest2","Cookie two");
String url = request.getContextPath()+"/servlet/myServlets.ShowSharedInfo";
url = response.encodeRedirectURL(url);


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.
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..
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Your servlets name is 'SetSharedInfo' but the URL is calling 'ShowSharedInfo' - try to change one of them.

[ October 11, 2002: Message edited by: Rene Larsen ]

Regards, Rene Larsen
Dropbox Invite
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 614
Sorry for not giving the whole scenario..
the inernally calls the
If I try to access this servlet it gives me NullPointer exception.
Nikki Aniban

Joined: Oct 10, 2002
Posts: 14
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!
I agree. Here's the link:
subject: where to look for the error...
It's not a secret anymore!