Tom Nicolas

Greenhorn
+ Follow
since Dec 30, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tom Nicolas

this is my comprehension about HttpSession,am i right?

'when the client visit the web application first time,the JVM create the HttpSession object for the client. so it created automatically '
18 years ago
if all codes were in the doGet(),it seems like any client visit this servlet by get method would always print the error code and message. But there is not exception.
18 years ago
so i think the code:
...
Integer code=(Integer)req.getAttribute("javax.servlet.error.status_code ");
String msg=(String)req.getAttribute("javax.servlet.error.message");
...
out.println(code);
out.println(msg);
..

should be in a try/catch filed like this:

try{
...
}catch(FileNotFoundException e){
...
Integer code=(Integer)req.getAttribute("javax.servlet.error.status_code ");
String msg=(String)req.getAttribute("javax.servlet.error.message");
...
res.setError(code,msg); //i think the setError() should be invoked here.
out.println(code);
out.println(msg);
..
}

but all that codes are in a doGet() method.

doGet(......){
...
Integer code=(Integer)req.getAttribute("javax.servlet.error.status_code ");
String msg=(String)req.getAttribute("javax.servlet.error.message");
...
out.println(code);
out.println(msg);
..
}

it puzzled me
18 years ago
i have got puzzled in this point for days,help me plz..

there are two attribute in error class:
javax.servlet.error.status_code -- an integer object refers to the error page code
javax.servlet.error.message--a string refers to the error message show the client

doGet(......){
...
Integer code=(Integer)req.getAttribute("javax.servlet.error.status_code ");
String msg=(String)req.getAttribute("javax.servlet.error.message");
...
out.println(code);
out.println(msg);
..
}

and it told me that when call sendError(...) or setStatus(...) the Errorservlet instance will distill the error code and the error message and show them in the error page.
like this: res.sendError(res.SC_NOT_FOUND,msg);
18 years ago