• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Display jsp result in header without effecting the body

 
Greenhorn
Posts: 22
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I've a jsp that get the sum from a database. and i want to show this on every webpage the user opens in header. Here totally there are 8 pages, right from the time the index page is opened, let it be any page the user opens, the header should be fixed. My current code is as below.

Index.jsp




and my Servlet is as below



Here everything is working fine. But the problem comes up with when i have multiple pages

I need the same above mentioned header in all the files. If i use a separate file and use a <jsp:include file/>, the entire page gets reloaded as a new page and shows the contents of new page.

Below example will give a better understanding.

I've 2 pages Index, counts these are JSPs.

There is some content in both index page, and the counts page is responsible for displaying counts (in the header) and it done in js using onload method.

When i run my program. The Index page is shown with its content and there would be a redirect to the counts.jsp and the content of counts.jsp is shown as a seperate jsp file, and the contents of index will be missing.

please let me know how can i do it. I want the result to be displayed in the header section itself without missing the body content.

A simple comparison would be with the frames that we use earlier. When we have a frame in header, what ever operations are done will be done there itself, it won't affect the entire age.

Thanks
 
Sheriff
Posts: 67756
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
If you don't want a page reload, fetch the count using Ajax, retiring the value as a JSON response. Use the value obtained to update the DOM rather than reload the entire page.

JSP is not needed for any of this unless you need JSP for something else.
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And do yourself a big favor and look into using jQuery. It pains me to see anyone writing raw JavaScript. It's like trying to build a house with a rock and a dull knife. You'll get it done eventually, but why put yourself through the agony when there are much better tools available?
 
reply
    Bookmark Topic Watch Topic
  • New Topic