Discussion Locked

servlets

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How to invoke a html file through a servlet?

4 replies

by rashmigopinath

If you have to make a call to the HTML file from your servlet, you would have to use the RequestDispatcher class. You can use either the include() or the forward() method based on your requirement.
Please refer to the Servlet docs for usage information.

Thanks,
Rashmi.

by pra_kie

simply use, response.sendRedirect(request.getContextPath()+"redirectionfile.htm");
-- this one is absolute fragment type redirection
--this one equvalent to
response.sendRedirect( " /redirectionfile.htm " );

or u can use relative fragment,

response.sendRedirect( "redirectionfile.htm" );

by saurabhambekar

I would advice you should use RequestDispatcher way and not the response.sendRedirect way. sendRedirect way is not good.

by chellaganesh

Hi,
If you want to generate Html output from the servlet, you need to write the Html code to the response object.

PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("Hola");
out.println("");
out.println("");
out.println(" HelloWorldEJB Says: ");
out.println(this.hw.hi());
out.println("");
out.println("");

If you want to call a HTML file you need to use the RequestDespatcher object

This discussion is closed to new replies.