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

Moderator: admin

Post Reply
ETS User

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

Post 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

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.

Guest

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

Post by Guest »

Ok, thanks for the clarification.

Cheers

Guest

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

Post 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>");

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests