• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to include a HTML in JSP at runtime?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 59
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 89
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic