Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 7th, 2007, 05:49 AM
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default My servlet problem

Hi,

I have Tomcat5.5 ,

I wrote code bellow :



package com.jspbook;

import javax.io.*;
import javax.servlet.*;
import javax.servlet.http;

public class HelloWord extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpSevletResponse response){

        response.setContentType("text/html");

        PrintWriter out = response.getWriter();

        out.println("<html>");

        out.println("<head>");
            out.println("<title>HelloWord</title>");
        out.println("</head>");

        out.println("<body>");
            out.println("<h1>salam be hamegi</h1>");
        out.println("</body>");

        out.println("</html>");
    }

}

and recieved these exceptions :

D:\Program Files\apache-tomcat-5.5.23\webapps\jspbook\WEB-INF\classes\com\jspbook\HelloWord.java:5: package javax.io does not exist
import javax.io.*;
^
D:\Program Files\apache-tomcat-5.5.23\webapps\jspbook\WEB-INF\classes\com\jspbook\HelloWord.java:7: cannot find symbol
symbol : class http
location: package javax.servlet
import javax.servlet.http;
                    ^
D:\Program Files\apache-tomcat-5.5.23\webapps\jspbook\WEB-INF\classes\com\jspbook\HelloWord.java:9: cannot find symbol
symbol: class HttpServlet
public class HelloWord extends HttpServlet {
                               ^
D:\Program Files\apache-tomcat-5.5.23\webapps\jspbook\WEB-INF\classes\com\jspbook\HelloWord.java:11: cannot find symbol
symbol : class HttpServletRequest
location: class com.jspbook.HelloWord
    public void doGet(HttpServletRequest request, HttpSevletResponse response){
                      ^
D:\Program Files\apache-tomcat-5.5.23\webapps\jspbook\WEB-INF\classes\com\jspbook\HelloWord.java:11: cannot find symbol
symbol : class HttpSevletResponse
location: class com.jspbook.HelloWord
    public void doGet(HttpServletRequest request, HttpSevletResponse response){
                                                  ^
D:\Program Files\apache-tomcat-5.5.23\webapps\jspbook\WEB-INF\classes\com\jspbook\HelloWord.java:15: cannot find symbol
symbol : class PrintWriter
location: class com.jspbook.HelloWord
        PrintWriter out = response.getWriter();
        ^
6 errors

If it's possible for you explain to me with detail.




 
Old April 10th, 2007, 07:12 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

the import statement import javax.io.*; is wrong, there is no javax.io package in java, use import java.io.*; instead.

Regards,
Rakesh

- Rakesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with servlet developer.ibm Servlets 1 September 12th, 2007 11:22 PM
Servlet Problem cziaul Servlets 2 April 28th, 2007 09:39 AM
servlet Problem discuss Servlets 3 February 6th, 2007 02:06 PM
servlet problem discuss Servlets 1 August 29th, 2006 10:03 AM
Servlet problem Ravi Kumar Servlets 1 June 20th, 2005 04:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.