Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help needed.....

 
arpit singla
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have following JSP in tomcat:
<html>
<head>
<title> test </title>
<script language="JavaScript">
// code
</script>
</head>
<table>
// code
<form>
// code for when sb. presses update button.
<a href="abc"> xyz </a>
</form>
</table>
</html>
I have link "xyz" which calls servlet "abc". Servlet abc simply prints out a line. But when I click on the link, it gives error Page cannot be found. I have servlet registered with tomcat.
Other servlets registered with tomcat are working fine. I am not able to figure out what the problem is with this new Servlet. If sb. could figure out the problem, that will be great.
Code of the servlet abc:
import java.lang.*;
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.*;
import java.sql.* ;
import java.io.*;
public class abc extends HttpServlet{
public void doGet( HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException {

PrintWriter out = response.getWriter();
out.println(" inside servlet ");

}//doGet ends
}// class ends
thanks a lot in advance.
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arpit,
What is the URL that is provided by your link that is supposed to call the servlet?
I think that this is your first servlet...
try the following:
1.put the *.class files of your servlet in the following path:
c:\tomcat\webapps\examples\web-inf\classes
2.your link that calls the servlet needs to have the following
URL:
http://localhost:8080/examples/servlet/YourServletClassName
I hope that this will work,
Regards,
Mac.
 
arpit singla
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jimi
i am putting my servlets in c:\tomcat\webapps\myfolder\web-inf\classes.
url i am giving is:
http:\\localhost:8080\servlet\myservlet
all other servlets are working the same way. but this one is not. i was wondering if there was some problem in the JSP, i have given above.
let me know where i am missing.
thanks for the reply
arpit
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
arpit,
no problem with your code. I have tried it just to be sure...
it is working with me, and the servlet prints "inside servlet"! I have put the class in the same path I have specified. then I have changed the url as follows:
<a href="http://localhost:8080/examples/servlet/abc"> xyz </a>
just try it...
Regards,
mac.
 
arpit singla
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jimi
i got the problem, didn't put my application name in the href.
terrible mistake !!
anyway thanks for ur help and checking up my code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic