This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes Embedding java applications in a web page with JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Embedding java applications in a web page with JSP" Watch "Embedding java applications in a web page with JSP" New topic
Author

Embedding java applications in a web page with JSP

And Green
Greenhorn

Joined: Sep 28, 2007
Posts: 26
Firstly, forgive my ignorance at the outset if this is an obvious and/or stupid question!

I have created a free standing java application which is basically a frame with some buttons in it:

import java.awt.*;
import java.awt.event.*;


public class FrameTester
{
public static void main (String[] args)
{
TempFrame frame = new TempFrame();
frame.setTitle("Frame Test");
frame.setVisible(true);

}
}
class TempFrame extends Frame implements ActionListener
{
//TempFrame constructor
public TempFrame()
{
//set framesize
final int DEFAULT_FRAME_WIDTH = 250;
final int DEFAULT_FRAME_HEIGHT = 150;
setSize (DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT);
//Using GridLayout manager
setLayout (new GridLayout(4,2));
setLocation(100,100);
setTitle("Students - Main Menu");

close = new Button("close");
close.addActionListener(this);
add(close);

inputBox = new Button("Input test");
inputBox.addActionListener(this);
add(inputBox);

testDialog = new TestDialog(this);
}


public void actionPerformed(ActionEvent e)
{

if (e.getSource()==close)
System.exit(0);

else if(e.getSource()==inputBox)
testDialog.setVisible(true);
}

private Button close, inputBox;
private Dialog testDialog;

}

class TestDialog extends Dialog implements ActionListener

{
public TestDialog(Frame f)
{
super(f,true);
setSize (600,500);
setTitle ("Test Writer");
setLocation(300,100);
setLayout(new GridLayout(2,2));
add(new Label("general input"));
student_number=new TextField(10);
//student_number.addKeyListener(this);
add(student_number);

clear=new Button("Clear (close!)");
clear.addActionListener(this);
add(clear);
}

public void actionPerformed(ActionEvent e)
{
if (e.getSource()==clear)
System.exit(0);
}


private Button clear;
private TextField student_number;
}

and I want to embed the frame "frame" in a web page.

Is there a way of using JSP (Beans or some other method) to embed this code into a web page, without substantially rewriting my code. Any tips or pointers in the right direction, most appreciated.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41173
    
  45
Sounds like a perfect scenario for applets.


Ping & DNS - my free Android networking tools app
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Embedding java applications in a web page with JSP
 
Similar Threads
Converting to binary and hex ?!?!?!?!?!?!
How to make a component place on frame
Binary Files ?
invalid use of "this" selector syntax
Sory, now I putted the code