Java Learning -038-javaweb_007--JSP action ID-Plugin

Source: Internet
Author: User

The plugin action is used to load a Java Applet or JavaBean component in a JSP page, as shown in the syntax format:

<jsp:plugin type= "Bean|applet"/>[code= "Classfilename"][codebase= "Classfiledirectoryname"][name= " InstanceName "][align=" Left|top|right|bottom|middle "][height=" Displaypixels "][width=" DisplayPixels "][hspace=" Leftrightpixels "][vspace=" Topbottompixels "][jreversion=" JDK Version "][<jsp:params][<jsp:param name=" ParameterName "value=" ParameterValue "/>][</jsp:params>][<jsp:fallback> can not start the plugin when the text message displayed to the user </ Jsp:fallback>]</jsp:plugin>

Parameter description:

Type= "Bean|applet"

The type of object that the file will execute must be.

[code= "Classfilename"]

The name of the Java class file that the plugin executes must include the class extension in the name, and the file must be in the directory indicated by the CodeBase property.

[codebase= "Classfiledirectoryname"]

The directory that contains the Java class that the plug-in will run or the path to the file directory.

[Name= "InstanceName"]

The bean or applet instance name makes it possible to communicate between a bean or an applet called by the same JSP file.

[align= "Left|top|right|bottom|middle"]

Sets the way in which the embedded program is displayed on the page.

[height= "Displaypixels"]

The height of the embedded program displayed in the page.

[width= "Displaypixels"]

The width of the embedded program displayed in the page.

[hspace= "Leftrightpixels"]

The embedded program displays space between the left and right sides of the page.

[vspace= "Topbottompixels"]

The embedded program displays the space between the top and bottom of the page.

[jreversion= "JDK Version"]

Java runtime Environment.

[<jsp:params]

A list of parameters.

[<jsp:param name= "parametername" value= "ParameterValue"/>]

Parameters.

The following is an example of a Java applet loading a picture in a JSP page to illustrate a simple example of using Java applets in a JSP.

appletimagedemo.jsp File source code is as follows:

<% @page    language= "java"    import= "java.util.Date"    session= "true"    contenttype= "text/html; Charset=utf-8 "    buffer=" 32kb "%>

Imagedemo.java File source code is as follows:

Import java.applet.*;import java.awt.*;import java.net.*;p ublic class Imagedemo extends applet{private image image;    Private Appletcontext context;    Private String height;        public void init () {context = This.getappletcontext ();        Get parameter String ImageURL = This.getparameter ("image");        if (ImageURL = = null) {ImageURL = "./jsp_800330.jpg";        } if (height = = null) {height = "330";            } try{URL url = new URL (this.getdocumentbase (), ImageURL);        Image = Context.getimage (URL);            }catch (malformedurlexception e) {e.printstacktrace ();        Display in Browser status bar Context.showstatus ("Could not load image!");        }} public void Paint (Graphics g) {context.showstatus ("Java Applet Image Demo");        G.drawimage (image, N, +, +, (), NULL);     g.DrawString ("http://www.cnblogs.com/fengpingfan/", 30, 560); } }

Open the browser, enter in the Address bar: http://localhost:8080/jsp/007/AppletImageDemo.jsp, the page appears as follows:

The Java applet,appletimagedemo.html page can also be used in HTML as follows:

Open the browser, enter in the Address bar: http://localhost:8080/jsp/007/AppletImageDemo.html, the page appears as follows:

At this point, Java Learning -038-javaweb_007-JSP Action Logo-plugin successfully completed, I hope this article can give beginners javaweb you a reference.

Finally, very grateful to the pro-stop, I hope this article can be pro helpful. Warmly welcome the kiss to discuss together and progress together. Thank you so much! ^_^

Java Learning -038-javaweb_007--JSP action ID-Plugin

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.