Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

execute only part of code

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to execute/refresh only a part of the whole code in a jsp page?
 
Saloon Keeper
Posts: 6389
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you mean by "refresh", but not executing parts of a page can be done with JSTL's if and choose statements.
 
anuradha adi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am sorry i did not deliver my question in a proper way. what i actually meant was...I want a specific part of my code in a jsp page to be executed based on a given time automatically. Like the refresh option in the jsp page..but the refresh option refreshes the whole page but i just want a prt of the code in the page to be executed or refreshed every 2 or 3 secs..
 
Tim Moores
Saloon Keeper
Posts: 6389
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds either like an embedded iframe, or a solution based on Javascript that reloads data via Ajax, and then recreates the relevant screen parts.
 
anuradha adi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont know how. can you help me
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello anuradha adi

JSP is a server side technology, which means that if you want to refresh the page you will have to perform a request to the server which will return the new page. It is not possible to just return part of a page through normal JSP mechanisms.

If you want to just refresh the table you will need to use javascript to make an ajax call to the server to get the data you need, and repopulate the table with this data.

i think ajax is easy for refresh part of the code.

I hope this will help for you.
 
Saloon Keeper
Posts: 22004
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Anhurada!

I think probably that you are using the word "code" wrong.

JSPs are primarily HTML templates designed to present a View to a client. There should not be a lot of executable code in the JSP. That's an obsolete and very hard-to-debug practice. Instead, the JSP should primarily be markdown language (HTML).

However, a popular thing to do these days is to do a partial page update for a client, where instead of replacing the currently-displayed page image (HTML) with a whole new one, you keep the majority of the currently-displayed client-side page and simply update parts of it. And you do that using AJAX.

That's my best guess on what you really want. If you can describe an abstract example of what you are expecting to see happen from the client viewpoint, we can probably offer more specific details.
 
She'll be back. I'm just gonna wait here. With this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic