This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
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

doubt in servlet execution.............

 
gopal kishan
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class ServletExcep extends HttpServlet
{
public void service(HttpServletRequest req,
HttpServletResponse res)throws ServletException,
IOException
{
res.setContentType("text/html");
PrintWriter out= res.getWriter();
out.println("TEST MESSAGE----");
try
{
int
statusCode=Integer.parseInt(req.getParameter("statusCode"));
out.println("statuscode--"+statusCode);
}
catch(Exception e)
{
res.sendError(500, " SORRY WRONG VALUE PASSED");
}

}
}

Here , if i run the file i am getting error
" HELP/NAVIGATION ERROR - File Not Found
Unable to find http://localhost:8090/examples/servlet/ServletExcep "

if i make comment from try block to catch block, the it shows message " TEST MESSAGE----- ".

i dont know whats wrong??/

please clarify..

thanks in advance
Gopal
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Check your servlet mapping in the web.xml. Include package statement in the first line of your servlet code. Recent tomcat version does not recognise the servlets without package.
bye for now
sat
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic