[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Call javascript from jsp

Posted on 2007-11-15
3
Medium Priority
?
5,380 Views
Last Modified: 2008-02-01
Hello Everyone,

I have a jsp page which acts as a template in the main page, the jsp page does not have any body tags,I want to call a javascript function within this jsp page whenever the page is loaded or refreshed. Usually in a html body tag you could call it in the onLoad event, how would i call it without the body tag.

Thank you
Harsha
0
Comment
Question by:gbvreddy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 20292682
What does the javascript do ?  
>how would i call it without the body tag.  
Doesn't the JSP output ultimately end up in the body tag of the enclosing page ?
0
 
LVL 35

Accepted Solution

by:
TimYates earned 1500 total points
ID: 20297330
You could try just sticking the javascript at the bottom of your template...  Then the full DOM won't have finished loading, but at least this part of it will have...

<div>
  <%= "Woo! I'm a JSP with no body" %>
</div>
<script type="text/javascript">
  alert( 'and I'm some javascript' );
</script>

Open in new window

0
 
LVL 35

Expert Comment

by:TimYates
ID: 20297333
(obviously, you should use valid javascript with no escaping errors like mine)

*blush*
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question