aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "where to look for the error..." Watch "where to look for the error..." New topic
Author

where to look for the error...

trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
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

Joined: Oct 12, 2001
Posts: 1179

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 ]

Regards, Rene Larsen
Dropbox Invite
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
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

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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: where to look for the error...