Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request Dispatcher issue

Status
Not open for further replies.

komyg

Programmer
Dec 13, 2005
68
BR
I have a HttpServlet that needs to send a html page when the browser calls it's doGet method, but this html page is not on the WebContent directory nor any of it's folders.

My doGet method looks like this:

ServletContext cont=super.getServletContext();

response.setContentType("text/html");

RequestDispatcher req=null;

req=cont.getRequestDispatcher("/build/gwtOutput/com.opus.Demo/Demo.html");

req.forward(request, response);

Where request is a HttpServletResquest interface, response is a HttpServletResponse interface and the path in the getRequestDispatcher method leads to the html file itself.

When I deploy the servlet using tomcat I get this error message:

The requested resource (/Demo/build/gwtOutput/com.opus.Demo/Demo.html) is not available.

What am I doing wrong?

Thanks,
Komyg
 
I don't see the point of a servlet pointing to an static page. Anyway, I'd take a look at sendRedirect method.

Cheers,
Dian
 
Well the thing is that I am using GWT (Google Web Toolkit) to generate this Demo.html, so it is not a static page.

I am using a GWT plugin Googlipse and it generates the html output page into a folder that is outside the WebContent.

I've tryed to use the sendRedirect, so I've typed the same path I used for the request dispatcher, but it didin't work out.

Do you have another suggestion?

Thanks,
Komyg
 
What was the error?

The next step is reading the html file and write the contents to the response.

Anyway, what about pointing to the generated html page?

Cheers,
Dian
 
GWT doesn't generates just 1 html page it is several and they are all conncted.

As for the error it was the same as before:

HTTP Status 404 - /Demo3RPC/build/gwtOutput/com.opus.Demo/Demo.html

type Status report

message /Demo3RPC/build/gwtOutput/com.opus.Demo/Demo.html

description The requested resource (/Demo3RPC/build/gwtOutput/com.opus.Demo/Demo.html) is not available.

Where Demo is my project and Demo3RPC is my servlet.

Thanks,
Komyg
 
404 is forbidden: the end user has no access to the genereted page, what's correct considering its outside the scope of the web application.

Did you try the second sollution? Anyway, I don't think it will work because there are many pages. I'd try getting the pages into the aweb applicattion.

Cheers,
Dian
 
this html page is not on the WebContent directory nor any of it's folders.

Hence the 404.

How do you expect the server to serve up a page that does not exist ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top