The moose likes JSP and the fly likes How to include a HTML in JSP at runtime? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "How to include a HTML in JSP at runtime?" Watch "How to include a HTML in JSP at runtime?" New topic
Author

How to include a HTML in JSP at runtime?

Balaji Krishnan
Greenhorn

Joined: Dec 14, 2011
Posts: 8
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 opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Balaji Krishnan
Greenhorn

Joined: Dec 14, 2011
Posts: 8
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

Joined: Feb 26, 2009
Posts: 59

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

Joined: Dec 14, 2011
Posts: 8
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

Joined: Jun 20, 2011
Posts: 85
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.
 
IntelliJ Java IDE
 
subject: How to include a HTML in JSP at runtime?
 
Threads others viewed
Simple examples of JSP
include file in jsp
JSP Include
How to include image in a JSP?
html within html?
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture