jeremybwilson
08-03-2009, 12:24 PM
Can anyone help me to convert the following PHP example into JSP? I know that I need to use out.print("something") but I'm unclear how I can incorporate my variable names prior to the variable values themselves.
Here is the PHP code:
$result = "OK";
$update = "1";
$updateid = "90094";
echo "result=".$result."\n";
echo "update=".$update."\n";
echo "updateid=".$updateid."\n";
Here is my JSP conversion so far. I am not clear on how I mimic the variable name prior to the variable value itself.
<c:set var="result">OK</c:set>
<c:set var="update">0</c:set>
<c:set var="updateid">NULL</c:set>
<%
// Respond to the application with 1) result, 2) update, and 3) updateid values
String result = "OK";
String update= "0";
String updateid= "NULL";
out.print("result=" + result);
out.print("update=" + update);
out.print("updateid=" + updateid);
%>
<p>You have the current version, version <c:out value="${versionmaj}"/>.<c:out value="${versionmin}"/>.<c:out value="${versionbld}"/> </p>
Another question would be, given that I've already used EL to declare the variables above, it seems like I am creating more work than is necessary. Would it be possible and how then would I replicate the PHP echo using <c:out value="${somevalue}"/>
Would this work for that:
<c:out value="somevalue=" + ${somevalue} />
Here is the PHP code:
$result = "OK";
$update = "1";
$updateid = "90094";
echo "result=".$result."\n";
echo "update=".$update."\n";
echo "updateid=".$updateid."\n";
Here is my JSP conversion so far. I am not clear on how I mimic the variable name prior to the variable value itself.
<c:set var="result">OK</c:set>
<c:set var="update">0</c:set>
<c:set var="updateid">NULL</c:set>
<%
// Respond to the application with 1) result, 2) update, and 3) updateid values
String result = "OK";
String update= "0";
String updateid= "NULL";
out.print("result=" + result);
out.print("update=" + update);
out.print("updateid=" + updateid);
%>
<p>You have the current version, version <c:out value="${versionmaj}"/>.<c:out value="${versionmin}"/>.<c:out value="${versionbld}"/> </p>
Another question would be, given that I've already used EL to declare the variables above, it seems like I am creating more work than is necessary. Would it be possible and how then would I replicate the PHP echo using <c:out value="${somevalue}"/>
Would this work for that:
<c:out value="somevalue=" + ${somevalue} />