Page 1 of 1

About Question com.enthuware.ets.scwcd.v5.2.487 :

Posted: Fri Jun 17, 2011 2:46 pm
by ETS User
Hi,

Can

Code: Select all

request.GetRequestDispatcher(String)
accept the name of a servlet as argument? I thought that only a resource url could be used...

Thanks

Re: About Question com.enthuware.ets.scwcd.v5.2.487 :

Posted: Sun Jun 19, 2011 6:26 pm
by admin
Hello,
ServletRequest's getRequestDispatcher is allowed to use paths that do not start with '/'. Such paths are considered relative to the current request path. In this question, relative path is being used. It is possible to define the path of a servlet to be same as the servlet class name. So it can be safely assumed that this path is valid because the question has nothing to do with the path.

To answer your question, no, you cannot pass a servlet name for the path. This question however does not claim that it is passing servlet name as an argument.


HTH,
Paul.

Re: About Question com.enthuware.ets.scwcd.v5.2.487 :

Posted: Mon Jun 20, 2011 8:54 am
by Guest
Ok, thanks for the clarification.

Cheers

About Question com.enthuware.ets.scwcd.v5.2.487 :

Posted: Fri Jul 13, 2012 1:53 am
by Guest
Can I still write to response even if the opening tags for <html><body> are not there?

What should be the output of the foll code?

PrintWriter out = response.getWriter();
out.println("<br>Page 2</body></html>");

Re: About Question com.enthuware.ets.scwcd.v5.2.487 :

Posted: Fri Jul 13, 2012 7:04 pm
by admin
Guest wrote:Can I still write to response even if the opening tags for <html><body> are not there?

What should be the output of the foll code?

PrintWriter out = response.getWriter();
out.println("<br>Page 2</body></html>");
What you write to the response is totally up to you. But in practice, it depends on what content you are generating. For example, most of the time, you generate HTML content, which is displayed by the browser. So if you do not generate correct or proper HTML data (such as not including <html> or <body> tag, the servlet container will not complain because it doesn't care what you generate. But the browser may not display the page correctly or as you expected.