将值从 applet 传递到 jsp

发布于 2024-11-01 08:49:00 字数 533 浏览 0 评论 0原文

import java.awt.*; 
import java.applet.*;

public class GuiExample extends Applet { 
    Button okButton; 
    TextField nameField;

    public void init() { 
        setLayout(null); 
        okButton = new Button("A button"); 
        nameField = new TextField("A TextField",100); 
        okButton.setBounds(20,20,100,30); 
        nameField.setBounds(20,70,100,40); 

        add(okButton); 
        add(nameField); 
    }

}

单击按钮时,如何将文本框中的值传递到“validate.jsp”? 我还希望浏览器转到那个jsp页面。并从那里继续执行? 我该如何修改代码?

import java.awt.*; 
import java.applet.*;

public class GuiExample extends Applet { 
    Button okButton; 
    TextField nameField;

    public void init() { 
        setLayout(null); 
        okButton = new Button("A button"); 
        nameField = new TextField("A TextField",100); 
        okButton.setBounds(20,20,100,30); 
        nameField.setBounds(20,70,100,40); 

        add(okButton); 
        add(nameField); 
    }

}

how can i pass the value in the textbox to the 'validate.jsp', when the button is clicked?
And i also want the browser to go to that jsp page. and continue execution from there?
How can i modify the code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素染倾城色 2024-11-08 08:49:00

这段代码可能会有所帮助。

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class GuiExample extends Applet { 
    Button okButton; 
    TextField nameField;
    GuiExample currentApplet; // needed for navigation

    public void init() {
        currentApplet = this;
        setLayout(null); 
        okButton = new Button("A button"); 
        nameField = new TextField("A TextField",100); 
        okButton.setBounds(20,20,100,30); 
        nameField.setBounds(20,70,100,40); 

        add(okButton); 
        add(nameField);

        okButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String text = nameField.getText();
                if (text != null) {
                    try {
                        // modify this to point to your website
                        String address = "http://www.example.com/validate.jsp?p=" + URLEncoder.encode(text, "UTF-8");
                        currentApplet.getAppletContext().showDocument(new URL(address));
                    } catch (Exception ex) {
                    }
                }
            }
        });

    }

}

This bit of code might be helpful.

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class GuiExample extends Applet { 
    Button okButton; 
    TextField nameField;
    GuiExample currentApplet; // needed for navigation

    public void init() {
        currentApplet = this;
        setLayout(null); 
        okButton = new Button("A button"); 
        nameField = new TextField("A TextField",100); 
        okButton.setBounds(20,20,100,30); 
        nameField.setBounds(20,70,100,40); 

        add(okButton); 
        add(nameField);

        okButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String text = nameField.getText();
                if (text != null) {
                    try {
                        // modify this to point to your website
                        String address = "http://www.example.com/validate.jsp?p=" + URLEncoder.encode(text, "UTF-8");
                        currentApplet.getAppletContext().showDocument(new URL(address));
                    } catch (Exception ex) {
                    }
                }
            }
        });

    }

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文