Javascript calls JSP

Source: Internet
Author: User

Example

 

Function circleonclick (EVT ){
VaR circle03 = evt.tar get
VaR id = circle03.getattribute ('id ')
Window. Location = 'HTTP: // localhost: 8080/MyApp/parse_draw.jsp? Xml = dblp. xml & author = '+ ID;
}

 

Or use the link

As follows:

For example
<% @ Page Language = "Java" contenttype = "text/html; charset = UTF-8"
Pageencoding = "UTF-8" %>
<%
String strstyle = request. getparameter ("style ");
String siteid = request. getparameter ("CID") = NULL? "": Request. getparameter ("CID ");
String requrl = request. getrequesturl (). tostring ();
Requrl = requrl. substring (0, requrl. lastindexof ("/"));
String prevdir = requrl. substring (0, requrl. lastindexof ("/") + 1 );
Requrl + = "/sitecounter. jsp ";
String linkto = prevdir + "admincounter/counter_admin.jsp ";
String IMG = prevdir + "images/05count.gif ";
%>
Document. Write ("<a target = 'blank 'href = '<% = linkto %>'> ");
Document. Write (" 'border = '0' width = '73 'height = '14'/> ");
Document. Write ("<SCRIPT type = 'text/JavaScript'
Src = '<% = requrl %>? Style = <% = strstyle %> & screenwidth = "+
Screen. Width + "& screenheight =" + screen. height + "& cid = <% =
Siteid %> '> ");
Document. Write ("</SCRIPT> </a> ");
Document. Write ("<SCRIPT type = 'text/JavaScript '> alert (' OK '); </SCRIPT> ");


Call it in HTML
<SCRIPT type = "text/JavaScript" src = "http: // localhost: 505/Kefu/visitcounter/webcounter/mycount. jsp"> </SCRIPT>
</Body>

Note:
1. single quotation marks and double quotation marks.
2. <SCRIPT> </SCRIPT> must be used in pairs.
3. jsp cannot contain the out. ** () statement.
4. Note tostring () Conversion When referencing JSP non-string variables in Js.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.