• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to include a HTML in JSP at runtime?  RSS feed

 
Balaji Krishnan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to include a html content into a JSP. But I will come to know about the JSP file where i need to include the html at runtime only. Please help me how to perform this.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66153
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Balaji Krishnan wrote:I need to include a html content into a JSP.

As with any other resource, run-time inclusion is accomplished via <jsp:include> or <c:import>

But I will come to know about the JSP file where i need to include the html at runtime only.

You will need to explain this more clearly.
 
Balaji Krishnan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
Basically i will search a keyword in a search text box. This keyword will have a 'URL' mapped to it.

So i will be redirected to the corresponding URL. Now here i need to include the html. Hope this clears you.
 
Ravi Majety
Ranch Hand
Posts: 59
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krishnan,

You can make use of ajax and servlets in this context. You can create a servlet which responds to the ajax request and returns the htmlcontent of the related keyword. At browser side, when the search button is clicked then in the background , send a request to the servlet using ajax with keyword as input parameter.

After you receieve the response you can
1. open an new window with responseText.
2. include the responseText as div innerHTML.

Hope it solves your problem.

 
Balaji Krishnan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ravi,

Thanks for your help here. I don't know anything about AJAX. I don't have open an new window to show the responseContent(html).

When i mention redirect, it will redirected to an existing screen in my application. This is where i need to include the HTML content without affecting page layout. Is this possible?

Sorry if i din't get your point correctly.
 
Tarun Bolla
Ranch Hand
Posts: 89
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Balaji Krishnan wrote:
When i mention redirect, it will redirected to an existing screen in my application. This is where i need to include the HTML content without affecting page layout

You can do that ...
From page A you will be sending a parameter to page B.
Page B will display the content that is relavant to the parameter.
What is the problem you are facing here? And as far as layout is concerned, you can always adjust your layouts according to your need. Sometimes you can solve things when you jumpstart the coding.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!