By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,412 Members | 1,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,412 IT Pros & Developers. It's quick & easy.

JSP error & Java class for rs232

P: n/a
I wnat to see in browser an status from an device connected on rs232

The java class for read from serial port is:

import java.util.*;
import java.lang.*;
import javax.comm.*;
public class Serial implements SerialPortEventListener

SerialPort port;
CommPortIdentifier ID;
InputStream in;
OutputStream out;
String text1="ok";

public void alarm(){

ID = CommPortIdentifier.getPortIdentifier("COM1");
port = (SerialPort)"alarm",1000);
in = port.getInputStream();
out = port.getOutputStream();
port.setSerialPortParams (19200, port.DATABITS_8, port.STOPBITS_1,
catch (Exception e) {}


public void serialEvent(SerialPortEvent e)
int data = 0;
String text1;

case SerialPortEvent.DATA_AVAILABLE:
while (in.available() > 0)
if ('S' == (char)data)
catch (IOException ev) {}

public String update_status (int s)
int temp = s;
int val = temp & 0x01;

if (val==0x01)
text1 = "ok";
text1 = "not ok";

return text1;

}//end class

Tha jsp page is :

<%@ page import="Serial" %>
<TITLE>Using a JavaBean</TITLE>

<% Serial rs232 = new Serial(); %>

The status is: <%= rs232.update_status() %>


I started Apache Tomcat 5.0 server (run on Winxp); I put RS232.jsp in
"webapps/Root" and Serial.class in "webapps/Root/WEB-INF/classes

On executing "http://localhost/RS232.jsp" I have an error :

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Compiling 1 source file

C:\Tomcat5\work\Catalina\localhost\_\org\apache\js p\
'.' expected
import Serial;
1 error

What can be wrong????
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: 4
hello, i'm hani. i'm learning to use servlet in read serial port. i'll try to run your program. the error is it can't read update_status(). only. have you figure what's wrong with the code. just want to know. thank you
Mar 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.