File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes ?? about js and redirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "?? about js and redirect" Watch "?? about js and redirect" New topic

?? about js and redirect

Yu Chen

Joined: Feb 11, 2002
Posts: 17
Hi all, if I have the following jsp file that is triggered when user clicks on a link through a JS onclick handler, would the JS code be executed first before the redirect ?

Thanks all.

String chName = request.getParameter("chName");
out.println("<script language=\"JavaScript\">");
out.println("var chName=\"" + chName + "\";");
<script language="JavaScript" type="text/javascript"><!--
if(eMetrics == true) {
var _rsCI="...";
var _rsCG=chName;
var _rsND=_rsLP+'//';
if (parseInt(navigator.appVersion)>=4) {
_rsCL='<scr'+'ipt language="JavaScript" type="text/javascript" src="'+_rsND+'v5.js"></scr'+'ipt>';
} else {
_rsCL='<img src="'+_rsND+'cgi-bin/m?ci='+_rsCI+'&cg='+_rsCG+'&si='+_rsSI+'&rp='+_rsRP+'">';
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31415

Yes, the javascript will execute first. I assume you set the target for the redirect in the Java code on the page and not the javascript?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Don't get me started about those stupid light bulbs.
subject: ?? about js and redirect