Vardan Gupta

Greenhorn
+ Follow
since Jun 02, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Vardan Gupta

Hello,

Problem I faced is that there are some variables which are going to be set in a thread at background but my JSP page has been loaded, i need to refresh page after 5 mins so that page reflect the new sessions variables without actually refreshing jsp page, please guide if ajax can help this ?
12 years ago
JSP
how can we implement javascript timer?
thank you himanshu for your kind review

i m planing to make a page consist of a question for which, there will be some time period to solve it, once time gone, page will direct to another.
please someone tell me how we can implement a Thread in JSP

I was making a code, which can accept packets, as well as receive packets, but due to some problem i m getting packet received but unable to send packet

this is the main source code


import java.awt.*;
import java.awt.event.*;
import java.net.*;
import javax.swing.*;

public class net9 extends Frame implements ActionListener,WindowListener
{
static DatagramSocket ds2;
JButton a=new JButton("Send");
JLabel b=new JLabel("Two Way Chatting");
static JTextField c=new JTextField(30);
static JTextArea d=new JTextArea(10,30);
net9() throws Exception
{

setLayout(new FlowLayout(FlowLayout.CENTER));
setBackground(Color.GREEN);
setForeground(Color.BLUE);
setSize(400,300);
setLocation(50,50);
addWindowListener(this);
add(b);
add(d);
add(c);
add(a);
a.addActionListener(this);
setVisible(true);

}


public void windowClosing(WindowEvent w)
{
System.exit(1);
}
public void windowDeiconified(WindowEvent w){}
public void windowIconified(WindowEvent w){}
public void windowClosed(WindowEvent w){}
public void windowActivated(WindowEvent w){}
public void windowDeactivated(WindowEvent w){}
public void windowOpened(WindowEvent w){}


public void actionPerformed(ActionEvent ae)

{
String z= c.getText();
byte m[]=z.getBytes();
try{
InetAddress ia =InetAddress.getLocalHost();
System.out.println(ia);

DatagramPacket dp3=new DatagramPacket(m,m.length,ia,45);
ds2.send(dp3);} catch(Exception e){}
c.setText("");
d.append("sent--"+z+'\n');
System.out.println(""+z);

}

public static void main(String args[])throws Exception
{


DatagramSocket ds2=new DatagramSocket(1);
net9 w=new net9();
while(true)

{
byte u[]=new byte[100];
DatagramPacket dp2=new DatagramPacket(u,u.length);
ds2.receive(dp2);
String g=new String(dp2.getData(),0,dp2.getLength());
System.out.println(g);
d.append("Recieved--"+g+'\n');
}
}
}


Source code of program which receive packets

//
to receive packet (U.D.P.)

Source code of program that send packet







Please help me out
What is java FX, will java be revisited by java fx?
15 years ago
leave all that, i just want to ask one thing that, if we use System.exit(1) as a body in any funcion then all the opened frames get lost, but suppose if we are having 1 applet window opened and 1 frame window opened in the same program and we are using aforesaid then there arise a problem, which i mentioned in my previous post.
Thanks
15 years ago

Vardan Gupta wrote:I was trying to make an applet which invokes a frame, and frame is implementing WindowListener and ActionListener but it gives an exception
Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
the coding done in listener is {System.exit(1);}
please help me out, i m a beginner in java.

15 years ago
I was trying to make an applet which invokes a frame, and frame is implementing WindowListener and ActionListener but it gives an exception
Exception in thread "AWT-EventQueue-1" java.security.AccessControlException
the coding done in listener is {System.exit(1);}
please help me out, i m a beginner in java.

15 years ago