473,382 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

JSP error & Java class for rs232

Dan
I wnat to see in browser an status from an device connected on rs232
port

The java class for read from serial port is:

//Serial.java
import java.io.*;
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(){

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

}

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

switch(e.getEventType())
{
case SerialPortEvent.DATA_AVAILABLE:
try
{
while (in.available() > 0)
{
data=in.read();
if ('S' == (char)data)
{
data=in.read();
update_status(data);
}
}
}
catch (IOException ev) {}
break;
}
}

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

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

return text1;
}

}//end class

Tha jsp page is :
//RS232.jsp

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

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

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

</BODY>
</HTML>

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\RS232_jsp.java:6:
'.' expected
import Serial;
^
1 error
//...........................

What can be wrong????
Jul 18 '05 #1
1 7793
hani
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
6
by: Przemo | last post by:
Hi, Do you know some good RS232C class? There is one in VB.NET 101 Examples, but I think it is poor. 1. I can't for e.g. read into my application all data received. I must tell how many...
6
by: Bruce | last post by:
I get this error on a line that references any control in the form_load sub: An unhandled exception of type 'System.NullReferenceException' occurred in BC785dProg1.exe Additional...
2
by: Mika M | last post by:
Ealier I have found Class called as Rs232. After importing it into project, it was easy to use for printing string to the COM-port like ... Dim p As Rs232 = New Rs232 p.Open("MyPortSettings...
2
by: Mika M | last post by:
Hi! My application uses Rs232-class, which was shipped with "101 VB.NET Samples\Framework - Using the COM Port". I need to sent certain kind of string into peripheral equipment attached to...
0
by: jereme.goblue | last post by:
The web page at http://www.rossowinspections.com/ has an issue with the left menu. The left menu has 7 links. One of the links doesn't work. Using Firefox 1.5 the Fees link isn't a clickable...
4
by: Dave Harry | last post by:
I found the RS232 class from MS's 101 VB samples. Writing to the port works fine. (I've got hyperterminal on the other comm port and a crossover cable between COM1 and COM2) The port is opened...
15
by: judge82 | last post by:
I made sure I closed all the bracket, why do i still get the error. on line 360, 424, 425 and 607 Please help /* * ShopCartServletHW3.java *
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.