Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics 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 July 14th, 2007, 01:23 AM
Authorized User
 
Join Date: Jun 2007
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default hi everybody.....need help????

hi
below is my servlet program:
...............................

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}

..................................................

I saved it in d:\java program\Helloworld.java.
................................................

at command prompt i typed:::::
D:\java program>javac Helloworld.java
......................................

error i got ::::
Helloworld.java:4: class Helloworld is public, should be declared in a file named Helloworld.java

.................................................. ...................
plse help me out??????


 
Old July 14th, 2007, 12:41 PM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The class is declared as HelloWorld with 'W' in uppercase. YOu have saved the file with 'w' in lower case. Hence the problem. Save the file as HelloWorld.java and try compiling. It should work.

-eNJay
 
Old July 14th, 2007, 11:28 PM
Authorized User
 
Join Date: Jun 2007
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by enjay
 The class is declared as HelloWorld with 'W' in uppercase. YOu have saved the file with 'w' in lower case. Hence the problem. Save the file as HelloWorld.java and try compiling. It should work.

-eNJay
.................................................. ......

thnx
compilation done correctly.
I put d class file .... HelloWorld... in the dir:::
C:\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes

in IE, as i typed:::::
http://localhost:8080/servlet/HelloWorld
follwing erors appears::::
............................

type Status report

message /servlet/HelloWorld/

description The requested resource (/servlet/HelloWorld/) is not available.

........................................
what should i do now??????
Do i need to create a web.xml file......


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

Apache Tomcat/5.0.28



 
Old July 16th, 2007, 01:16 PM
Authorized User
 
Join Date: Apr 2005
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yup, add the servlet and its pattern in the web.xml file of that context.

-eNJay
 
Old July 26th, 2007, 05:10 AM
Authorized User
 
Join Date: May 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

java is case sensitive

http://studyjava.org/forums/









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