I need to read client comport accessing my JSP based web application.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>COMPORT</title>
</head>
<body bgcolor="blue">
<h1>ACCESSING COMPORT</h1>
<jsp:plugin align="middle" height="500" width="500" type="applet" archive="" code="SunCommSerialPort.class" name="clock" codebase="."/>
</body>
</html>
This is my Java applet code to read COM port.
import java.util.Enumeration;
import javax.comm.CommPortIdentifier;
/** @author Venugopal */
public class COMPORT {
/** @param args the command line arguments */
public static void main(String[] args) {
COMPORT CM = new COMPORT();
String StrCommPort = CM.GetSerialPort();
System.out.println("StrCommPort " + StrCommPort);
}
public String GetSerialPort() {
String Serialport = "";
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
Serialport = Serialport + portId.getName() + "//";
} else {
// ////////////System.out.println(portId.getName());
}
}
if(Serialport !=null && Serialport.length() >0){
Serialport = Serialport.substring(0, Serialport.length() - 2);
}
return Serialport;
}
}
Please tell us what to do.I have kept all necessary files at correct place.
The Java code I have kept here was working after that I have modified extending applet and removing PSVM with init()
method.