Tony Huang

Greenhorn
+ Follow
since Sep 09, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Tony Huang

Another post says it's an error of the book
https://coderanch.com/t/506641/java-Web-Component-SCWCD/certification/jsp-useBean-class-attribute

I tried to write a servlet and jsp file as specified and it worked well
the page prints:
Name is: Evan
11 years ago
JSP

Ryan McClain wrote:I know this topic is old, but I would like to add something very, very important.

If you have read other people's posts on this specific topic (404 not found, first servlet example) and you still can't get it to work,
well.. here is the solution:

Remove the / at the end of the URL. (xxxx = tomcat port)
It should then be: http://127.0.0.1:xxxx/ch1/Serv1

I have been pulling out my hairs on this specific problem for two hours and the solution was to remove the last /
It's just.. crazy.

In conclusion, the most common reasons why you are getting a 404 on this example are:

- you need to change ISO-8851-1 to ISO-8859-1 in your web.xml file that is present under the ch1/WEB-INF/ directory under your tomcat/web-apps directory.
- you need to remove the last forward slash from your URL, because you wrote the example just like in the book, without the / in the <url-mapping>. Remember? It was /Serv1. There is no extra / there.
More fundamentally, a lot of webservers (such as Apache) allow http://my.domain.com to be written as http://my.domain.com/ (first it gives a 301 'moved', but then later fixes this error implicitly by itself).

I'm actually glad I am following the book, doing everything hard coded in notepad.
This is how I catch these hard to find problems.

Sincerely,

--
Ryan



Thanks Ryan, changing ISO encoding solves my problem.