Hello, I am trying to communicate back to desktop application that is sending a number of parameters to a web page I've created via HTTP POST and having difficulty determining how exactly one responds back, not to another web page but in what strikes me as somewhat of a "broadcast to the world" method.

The platform for my pages is Tomcat 5.5.17 within an OpenCMS 6 environment.

On this page, I am expecting some parameters via HTTP POST to be sent to a URL I've created.

At a minimum, I am trying to parse these post values and return information to the application, which the Network Monitor/Nettrace logs show me as my local machine's IP address.

I've never done this before and have only a basic exposure to JSP but do have some ASP methods to reference for ideas.

Anyway, when I send values to this page via HTTP POST I do not see any activity in the Network Monitor trace. I believe it is because I am confused about what response methods to use in JSP.

The application is sending me five parameters. I am supposed to parse and match these and send back three in return.

Those are:

result=OK|ERR
update=1|0
updatedid=[Go-ID]|NULL (Go-ID being a predetermined five digit integer value)

Here is my code. Am I going about this the right way and if not, can you please provide me with an alternative example in a scriptlet format.

Code:
<%@ page session="false" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<%@ taglib uri="http://jakarta.apache.org/taglibs/regexp-1.0" prefix="rx" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/string-1.1" prefix="str" %>

<%@ page import="java.net.*"%> 
<%@ page import="javax.servlet.http.*"%>
<%@ page import="javax.servlet.http.HttpServletRequest"%> 
<%@ page import="javax.servlet.http.HttpServletResponse"%>

<jsp:useBean id="cms" class="org.opencms.jsp.CmsJspActionElement">
<% cms.init(pageContext, request, response); %>        
</jsp:useBean>          

<%
// Get the POST parameters from installer .EXE - should be passed in the HTTP POST request

String product = request.getParameter("product");
String language = request.getParameter("language");
String versionmajor = request.getParameter("versionmajor");
String versionminor = request.getParameter("versionminor");
String versionbuild = request.getParameter("versionbuild");
%>

<!-- set the current version numbers here -->
<!-- product and language values for Some Product 11.5.4165  ***** -->
<c:set var="currentProduct">Some Product</c:set>
<c:set var="prod" value="${param.product}" />

<c:set var="currentLanguage">EN</c:set>
<c:set var="lang" value="${param.language}" />

<!--  major, minor and version build values for Some Product 11.5.4165  ***** -->
<c:set var="currentMajor">11</c:set>
<c:set var="versionmaj" value="${param.versionmajor}" />
<c:set var="currentMinor">5</c:set>
<c:set var="versionmin" value="${param.versionminor}" />
<c:set var="currentBuild">4165</c:set>
<c:set var="versionbld" value="${param.versionbuild}" />


<c:choose>
	<c:when test="${prod == currentProduct}">
		<c:choose>
			<c:when test="${versionmaj == currentMajor}">
				<c:choose>
				<c:when test="${versionmin == currentMinor}">
				<!--  product and major version HTTP POST parameters  passed match   ******** -->
					<c:set var="result">OK</c:set>
					<c:set var="update">0</c:set>
					<c:set var="updateid">NULL</c:set>


					<% response.setStatus(response.SC_OK); %>
					<% response.setContentType("text/html"); %>

					<% response.setHeader("result", "OK"); %>
					<% response.setIntHeader("update", 0); %>
					<% response.setHeader("updateid", "NULL"); %>

				</c:when>
				<c:when test="${versionmin < currentMinor}">
				<!--  product and major version HTTP POST parameters  passed match   ******** -->
					<c:set var="result">OK</c:set>
					<c:set var="update">1</c:set>
					<c:set var="updateid">90017</c:set>

					<% response.setStatus(response.SC_OK); %>
					<% response.setContentType("text/html"); %>

					<% response.setHeader("result", "OK"); %>
					<% response.setIntHeader("update", 1); %>
					<% response.setIntHeader("updateid", 90017); %>

				</c:when>
				</c:choose>
			</c:when>
		</c:choose>
	</c:when>

	<c:when test="${prod != currentProduct}">
		<!-- do something in the event that none of the above parameters sent from application are matched -->
		<!--  user HTTP POST parameters are less than major and minor versions specified above  ******** -->
		<c:set var="result">ERR</c:set>

		<% response.setStatus(response.SC_OK); %>
		<% response.setContentType("text/html"); %>

		<% response.setHeader("result", "ERR"); %>


	</c:when>

	<c:otherwise>
	<!--  user come to the page with no URL parameters  ****************** -->
	<c:set var="result">ERR</c:set>
		
		<% response.setStatus(response.SC_OK); %>
		<% response.setContentType("text/html"); %>

		<% response.setHeader("result", "OK"); %>
		<% response.setIntHeader("update", 0); %>
		<% response.setHeader("updateid", "NULL"); %>

	</c:otherwise>
</c:choose>
The other problem I am seeing is that when you access the page with no HTTP POST parameters, I get an internal server error. The OpenCMS error details are as follows:

Code:
java.lang.NullPointerException
	at org.apache.jsp.WEB_002dINF.jsp.offline.sites.go.index_html_jsp._jspService(index_html_jsp.java:112)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
	at org.opencms.flex.CmsFlexRequestDispatcher.includeExternal(CmsFlexRequestDispatcher.java:194)
	at org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexRequestDispatcher.java:170)
	at org.opencms.loader.CmsJspLoader.service(CmsJspLoader.java:433)
	at org.opencms.flex.CmsFlexRequestDispatcher.includeInternalWithCache(CmsFlexRequestDispatcher.java:423)
	at org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexRequestDispatcher.java:174)
	at org.opencms.loader.CmsJspLoader.dispatchJsp(CmsJspLoader.java:467)
	at org.opencms.loader.CmsJspLoader.load(CmsJspLoader.java:412)
	at org.opencms.loader.CmsResourceManager.loadResource(CmsResourceManager.java:719)
	at org.opencms.main.OpenCmsCore.showResource(OpenCmsCore.java:1332)
	at org.opencms.main.OpenCmsServlet.doGet(OpenCmsServlet.java:151)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Thread.java:595)
I would prefer not to see any error here but I'm not sure what I'm doing or "not doing" here that is creating this error.