This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Html contents displayed by servlet

 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three file html, servlet and jsp. When i print html contents using servlet after user clicking on submit button then the html file(first file) content are replaced by the html_content of servlet.But if the servlet also forwords the request to JSP then what happens to the htnl_content in the servlet??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i tried it .. it overwrites it... Is it possible to retain the page displayed by servlet
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you actually trying to accomplish? What you are doing doesn't follow any established pattern of web application structure.
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:What are you actually trying to accomplish? What you are doing doesn't follow any established pattern of web application structure.

I understand what you are trying to say but i was just trying to do different things & it happened that i had html in the servlet and that servlet also forwards the call to JSP. So this question came to me ... what happens to the html of the servlet.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"the html of the servlet" has no meaning. You'll need to specific about what you mean by this.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What your looking for would be RequestDispatcher forward vs include.
You'll get a good understanding by googling for the difference or you could try it out yourself - http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/RequestDispatcher.html

As Bear has already pointed out - its against any established pattern of web application structure - so I would not end up using some code like that in a real application. (Basically under usual circumstances I would not have RequestDispatcher.include() in my Servlet!!)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic