Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher Include

 
john krem
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
john krem
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic