Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Internal Server Error page

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wich code inside the catch block is supposed to trigger the display of a container generated HTTP Internal Server Error page ?

"response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)" or
"throw new ServletException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);"

?

tks.
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it be the first option(sendError) because it says "generated an error page" ?

Tks.
 
Saurabh Chaubey
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Felipe,
I think the first option will give the desired output for error500.
Reagarding the second option there is no constructor for ServletException which takes int as the first argument. The valid costructors are as follows:

public javax.servlet.ServletException();
public javax.servlet.ServletException(java.lang.String);
public javax.servlet.ServletException(java.lang.String,java.lang.Throwable);

public javax.servlet.ServletException(java.lang.Throwable);

So, the first option is correct.

Regards,
Saurabh
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hum, you�re dead right Saurabh , there is no constructor like that.
I dind�t get that.

Anyway, if we had somethig like this: "throw new ServletException("String")", i�m also think that the correct answer would be the "sendError()"

Tks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic