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.

Java Code:
<%@ page session="false" %>

<%@ 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:

java.lang.NullPointerException
at org.apache.jsp.WEB_002dINF.jsp.offline.sites.go.in dex_html_jsp._jspService(index_html_jsp.java:112)
at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.doI nclude(ApplicationDispatcher.java:574)
at org.apache.catalina.core.ApplicationDispatcher.inc lude(ApplicationDispatcher.java:499)
at org.opencms.flex.CmsFlexRequestDispatcher.includeE xternal(CmsFlexRequestDispatcher.java:194)
at org.opencms.flex.CmsFlexRequestDispatcher.include( CmsFlexRequestDispatcher.java:170)
at org.opencms.loader.CmsJspLoader.service(CmsJspLoad er.java:433)
at org.opencms.flex.CmsFlexRequestDispatcher.includeI nternalWithCache(CmsFlexRequestDispatcher.java:423 )
at org.opencms.flex.CmsFlexRequestDispatcher.include( CmsFlexRequestDispatcher.java:174)
at org.opencms.loader.CmsJspLoader.dispatchJsp(CmsJsp Loader.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(OpenCmsC ore.java:1332)
at org.opencms.main.OpenCmsServlet.doGet(OpenCmsServl et.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.in ternalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invo ke(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.invok e(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.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 causing this page to kick back an 500 error in the event that no POST parameters are being thrown at it.