The Artima Developer Community
Sponsored Link

Java Answers Forum
servlet help

3 replies on 1 page. Most recent reply: Feb 26, 2006 7:56 PM by alexandra smith

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
akash sarkar

Posts: 2
Nickname: akash841
Registered: Feb, 2006

servlet help Posted: Feb 17, 2006 12:04 PM
Reply to this message Reply
Advertisement
i have just started learning servlet and following book name budi kurniawan so me beggnier.
i am using jdk1.5.0 and tomcat4.1 both of whiich instal in C:\ ,now under tomcat4.1i did this C:\Tomcat 4.1\webapps\akash\WEB-INF\classes and put my 1st servlet prog(as given below)
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class TestingServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Servelet Testing</TITLE>");
out.println("</HEAD>");
out.println(" out.println("welcome to akash home");
out.println(" out.println("</HTML>");
}
}
as well as the compiled file that is .class file in it.after that i created web.xml file (as given below)
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>
Testing
</servlet-name>
<servlet-class>
TestingServlet
</servlet-class>
</servlet>
</web-app>
and put it under C:\Tomcat 4.1\webapps\akash\WEB-INF directory
but after starting tomcat whenever i am trying to run the servlet(using this) http://localhost:8080/akash/servlet/Testing i am getting this(given below)
HTTP Status 404 - akash/servlet/Testing

-------------------------------------------------------- ------------------------

type Status report
message akash/servlet/testing
description The requested resource (akash/servlet/testing) is not available.

------------------------------------------------------------------- -------------

Apache Tomcat/4.1.29
so what is the problem and how can i amke it to run
help me plez
akash


ravi geda

Posts: 1
Nickname: ravii
Registered: Feb, 2006

Re: servlet help Posted: Feb 22, 2006 12:56 AM
Reply to this message Reply
In addition to the <servlet> tag in web.xml u have to add one more tag below that. So ur web.xml should contain

<servlet>
<servlet-name>servlet name</servlet-name>
<servlet-class>servlet class</servlet-class>
</servlet>

<servlet-mapping>
<servl et-name>servlet name</servlet-name>
<url-pattern>/url to access</servlet-pattern>
</servlet-mapping>

akash sarkar

Posts: 2
Nickname: akash841
Registered: Feb, 2006

Re: servlet help Posted: Feb 24, 2006 7:08 AM
Reply to this message Reply
hi,
thanx for ur reply
i tried ur suggestion but it didn,t working
just say what to write at the plase of URL under
<url-pattern>/url to access</servlet-pattern>
i also want to say u some thing when i am placing
my compiled .class file under examples folder it working fine
any way help me
thanx again for ur reply
akash

alexandra smith

Posts: 1
Nickname: lexa
Registered: Feb, 2006

Re: servlet help Posted: Feb 26, 2006 7:56 PM
Reply to this message Reply
I'm using the same book! I had problems too, thanks for the idea of dropping in examples folder. This is what I got to work:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<servlet>
<servlet-name>TestingServlet1</servlet-name>
<servlet-class>TestingServlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestingServlet1</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
</web-app>

Flat View: This topic has 3 replies on 1 page
Topic: xml parsing innovation Previous Topic   Next Topic Topic: jsp extracting data from files

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use