Meaningless Drivel is fun!
The moose likes Servlets and the fly likes RequestDispatcher Include Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher Include" Watch "RequestDispatcher Include" New topic

RequestDispatcher Include

john krem

Joined: Feb 06, 2011
Posts: 22
Can anyone clarify the include for me?

My understanding is that I can:

which I have in my doGet(), and that should include the order.html file:

This isn't working, so I'm wondering if my understanding is correct and I'm just implementing it wrong?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

It's be much more common to forward rather than include (once the resource is included, what else would you be doing in the servlet)?

In any case, please explain "not working". It could mean anything.

Is the HTML file located in the root of the web context? That's where your path says it should be.

[Asking smart questions] [About Bear] [Books by Bear]
john krem

Joined: Feb 06, 2011
Posts: 22
Here is my setup now.

That is my start page. The user selects which item they want and it then takes me to my servlet:

In the servlet, I am populating the user inputs and creating a textbox that I want the user to be able to enter a quantity of the number of orders of each item they would like.
I have the forward working fine, where if they do not select anything, they get forwarded to the error page.

With my order.html page, I only have a button that I am trying to get to show up on the servlet. I want to use the button to calculate the quantities that the user inputs in the textboxes for each item.

My understanding is that, if I use the include, the button from the order.html should show up on the servlet page, and I can then use that button to do my calculations?
john krem

Joined: Feb 06, 2011
Posts: 22
Odd, it works as expected if I include a .jsp page, but not an .html page but the api says:

include(ServletRequest request, ServletResponse response)
Includes the content of a resource (servlet, JSP page, HTML file) in the response.


found the problem - working now.
I agree. Here's the link:
subject: RequestDispatcher Include
It's not a secret anymore!