package tagclass.login; import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.*; import java.io.*; public class login extends TagSupport { public login() { super(); } public int doStartTag() throws JspTagException { JspWriter out = pageContext.getOut(); try { out.println("<APPLET CODEBASE=applet/login/ CODE=login.class width=200 height=100 > </APPLET>"); } catch(Exception e) { } return SKIP_BODY; } publicc int doEndTag()throws JsptagException { return EVAL_PAGE; } public void release() { super.release(); } public void setWidth(String language) { this.width = width; } public String getWidth() { return this.width; } public void setHeight(String height) { this.height=height; } public String getHeight() { return this.height; } private String width; private String height; }
标记符处理程序中所使用的Applet : login.java
import java.awt.*; import java.awt.event.*; import java.applet.*; public class login extends Applet implements ActionListener { private String s_username; private String s_userpassword; private Button b_ok; private Button b_register; private Label l_username; private Label l_userpassword; private TextField t_username; private TextField t_userpassword; private GridLayout g_gridlayout; public void init() { b_ok=new Button("ok"); b_register=new Button("register"); l_username= new Label("name"); l_userpassword=new Label("password"); t_username=new TextField(); t_userpassword=new TextField(); b_ok.addActionListener(this); b_register.addActionListener(this); g_gridlayout=new GridLayout(3,2,10,10); this.setLayout(g_gridlayout); //this.setBackground(Color.blue); add(l_username); add(t_username); add(l_userpassword); add(t_userpassword); add(b_ok); add(b_register); } public void actionPerformed(ActionEvent ev) { String s_label=ev.getActionCommand(); if (s_label.equals("ok")) { t_username.setText("name"); } if (s_label.equals("register")) { t_userpassword.setText("password"); } } public void paint(Graphics g) { } }