• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

where to look for the error...

 
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
On top of spaghetti all covered in cheese, there was this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic