- my file stored in D:\project1\src\Ch1Servlet.java and the web.xml stored in D:\project1\etc\web.xml
Thank you
Suraj Jadhav
Greenhorn
Joined: Mar 10, 2010
Posts: 25
posted
0
First of all it looks like there are compilation error in your code. You first need to resolve those error. Did you copied the html contains from some editors. Because compiler is saying that there are special characters in your code. I will suggest rather that use IDE like Eclipse rather than plain notepad if you are new to Java. IDE will point out the common error before compiling.
Second problem that you are getting is while compiling your code.
First make sure that you have set JAVA_HOME properly. Also servlet jar are in classpath. I could see that you have given wrong path.
It should be d:/project1/tomcat/common/lib/ where / should be after d:
Head First servlet and JSP is a great book. Compilation details that are given in first chapter is related to Mac OS and I guess you are using Windows. You need to make little changes in command while compiling your code.
This has nothing to do with the book, but with the tools that you are using. Something along the way is turning the normal quotes into invalid characters.
gong pex
Ranch Hand
Joined: Oct 27, 2011
Posts: 32
posted
0
I have tools like:
- notepad ++
- wordpad and ms office
so,what's tool that can I use to build servlets (if from these tool can't be use, I'll downloaded other)?
Use Notepad++. WordPad and MS Word often don't use " and ' for quotes but replace these with better looking alternatives. While that's OK for pieces of text, it's a nightmare for pieces of code.
If you are using Notepad++, you have an option to display all characters in your current document. (View-> Show all Characters) This will help you to check what are the special characters are available in document. As mentioned above some of the tools does inserting of special characters.
No pain, No gain.
OCJP 1.6
gong pex
Ranch Hand
Joined: Oct 27, 2011
Posts: 32
posted
0
First make sure that you have set JAVA_HOME properly. Also servlet jar are in classpath. I could see that you have given wrong path.
It should be d:/project1/tomcat/common/lib/ where / should be after d:
Head First servlet and JSP is a great book. Compilation details that are given in first chapter is related to Mac OS and I guess you are using Windows. You need to make little changes in command while compiling your code.
about JAVA_HOME, Is it like this ?
(on attachment : JAVA_HOME.png)
I have use notepad ++ and display all characters (View->Show all Characters) and this the image :
(on attachment : ntp++.png)
In book JSP (Head Servlet and JSP) I think it using JVM,
please told me how to type in command prompt fully. Because I really confused
Hey gong pex, don't be hurry to solve the problem. Analysis the problem and understand what causes it. Seems your special character problem have solved. After seeing your attachments I suggest you to do the following things:
* In your Ch1Servlet.java, println function have extra unary character "+" at line number 14. Remove this either in end of line 13th or in 14.
* To compile Servlets you need to have "servlet-api.jar" in your classpath. If you have any web/app server, it should there in lib folder.
Follow the habit of analyzing the compilation error, it will be good for you to learn more.
gong pex
Ranch Hand
Joined: Oct 27, 2011
Posts: 32
posted
0
In your Ch1Servlet.java, println function have extra unary character "+" at line number 14. Remove this either in end of line 13th or in 14.
yeah you right, there is excess + sign in my file.
To compile Servlets you need to have "servlet-api.jar" in your classpath. If you have any web/app server, it should there in lib folder.
I never compile using servlet-api.jar, can you tell me (in command prompt) at least give me an example.