I am developing a web SNMP manager using JSP/Servlet. In the application, i have a java class which needs to keep on listening to a port after being call by JSP. Problem is because the java class must keep on listening to a port which mean the JSP will keep on compiling without end. Even after the java class stops, the JSP still continue to wait or worst, the java class won't be executed again when the JSP is run again because JSP only compiles the first time it runs. Is there any way to do this?
Only solution i can think of is after executing the java class through jsp, i let the java class to write any reply into database. Then i retrieve the data from database using another JSP/servlet. Still the jsp that first calls the java class still stuck there waiting for localhost.
The java class that is listening, (for ever?). i think it needs to spawn (sorry if that is old C terminology) a thread that will do the listening, so that the servlet doesn't hang.
The resultas from this thread need to be put somewhere, maybe a database.