aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher Include" Watch "RequestDispatcher Include" New topic
Author

RequestDispatcher Include

john krem
Greenhorn

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
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

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] [Bear's FrontMan] [About Bear] [Books by Bear]
john krem
Greenhorn

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
Greenhorn

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: RequestDispatcher Include
 
Similar Threads
My java applet program does not appear in appletviwere!!!
Request Attribute confusion
including a css file to a jsp from another folder
Not able to set attribute in JSP
The import cannot be resolved