CharleneS77
asked on
How do I deploy and run this JSP Web Application locally?
I am using Tomcat 6.0 through port 8282. My operating system is Windows XP. I am able to deploy and run other JSP Web Applications without errors. The attached (zipped) folder is located at I:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ on my local machine. When I attempt to deploy and run the attached JSP Web Application locally (http://localhost:8282/DistanceCalculator2/distanceCalculator2.jsp), I get the error below. What is causing this error? Thank you in advance!
Note: I have added .txt extensions to the end of each file because the other filetypes (.jsp, .java, and .class) are not able to be uploaded here.
Note: I have added .txt extensions to the end of each file because the other filetypes (.jsp, .java, and .class) are not able to be uploaded here.
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.lang.NoClassDefFoundError: calc/DistanceCalc2 (wrong name: DistanceCalc2)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:274)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
DistanceCalculator2.zip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If I use
<form method="post" action="distanceCalculator 2.jsp">
nothing happens when I click on the Calculate button.
If I use
<form method="post">
nothing happens when I click on the Calculate button.
<form method="post" action="distanceCalculator
nothing happens when I click on the Calculate button.
If I use
<form method="post">
nothing happens when I click on the Calculate button.
>nothing happens when I click on the Calculate button.
What do you mean by "nothing" ? Does the form submit a request ? No error mesages ? If you change to
action="someOtherPage.jsp"
does it go there ?
What do you mean by "nothing" ? Does the form submit a request ? No error mesages ? If you change to
action="someOtherPage.jsp"
does it go there ?
ASKER
>>>What do you mean by "nothing" ?
When I click the Calculate button, no output is displayed.
>>>Does the form submit a request ?
How do I determine whether a request was submitted?
>>>No error mesages ?
No error messages.
>>>>If you change to action="someOtherPage.jsp" does it go there ?
Yes, I moved currentTime.jsp to the same directory and it did go to currentTime.jsp.
When I click the Calculate button, no output is displayed.
>>>Does the form submit a request ?
How do I determine whether a request was submitted?
>>>No error mesages ?
No error messages.
>>>>If you change to action="someOtherPage.jsp"
Yes, I moved currentTime.jsp to the same directory and it did go to currentTime.jsp.
>When I click the Calculate button, no output is displayed.
Is there anything in the page source in the browser ?
Is there anything in the page source in the browser ?
ASKER
When I right click on the page and select View Source, I see the following:
<html>
<head><title>JSP Distance Calculator using EL Statements, JSTL, and a JavaBean</title> </head>
<body>
<font face="Verdana"><center><i>
<h1>JSP Distance Calculator using EL Statements, JSTL, and a JavaBean</h1>
</i></center></font>
<form method="post" action="distanceCalculator2.jsp">
<br>
<font size="2" face="Verdana">
Please enter the value of X1:
<font color="blue">*</font>
<input type="text" name="x1" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of Y1:
<font color="blue">*</font>
<input type="text" name="y1" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of X2:
<font color="blue">*</font>
<input type="text" name="x2" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of Y2:
<font color="blue">*</font>
<input type="text" name="y2" length="7"/>
</font>
<p>
<input type="submit" value="Calculate"/>
</p>
</form>
</body>
</html>
I copy and pasted your last post and it displays in my browser(IE 7). You still see nothing in your browser window ?
ASKER
>>>>I copy and pasted your last post and it displays in my browser(IE 7). You still see nothing in your browser window ?
Did you copy and paste the html that I got from View Source? Are you able to get result for the distance between the two points? How?
Did you copy and paste the html that I got from View Source? Are you able to get result for the distance between the two points? How?
>Did you copy and paste the html that I got from View Source?
Yes.
>Are you able to get result for the distance between the two points? How?
I didn't test that yet.
Yes.
>Are you able to get result for the distance between the two points? How?
I didn't test that yet.
meanwhile add this inside your <c:choose> tag
<c:otherwise>
something is wrong, I'll keep looking
</c:othewise>
<c:otherwise>
something is wrong, I'll keep looking
</c:othewise>
no add this
<c:otherwise>
rrz${distance2.status}rrz
</c:othewise>
<c:otherwise>
rrz${distance2.status}rrz
</c:othewise>
ASKER
When I added the <c:otherwise> tag after the last <c:when> tag, and inside the <c:choose> tag, I get the following error:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /distanceCalculator2.jsp(94,3) The end tag "</c:othewise" is unbalan
try again with my last post
ASKER
I still get the same error:
HTTP Status 500 -
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx ception: /distanceCalculator2.jsp(9 4,3) The end tag "</c:othewise" is unbalanced
Below is what I have in the <c:choose> tag:
HTTP Status 500 -
--------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx
Below is what I have in the <c:choose> tag:
<c:choose>
<c:when test="${distance2.status == -1}">
<hr/>
Please input a value for X1.
</c:when>
<c:when test="${distance2.status == -2}">
<hr/>
Please input a value for Y1.
</c:when>
<c:when test="${distance2.status == -3}">
<hr/>
Please input a value for X2.
</c:when>
<c:when test="${distance2.status == -4}">
<hr/>
Please input a value for Y2.
</c:when>
<c:when test="${distance2.status == 1}">
<hr/>
<font face="Verdana"> <u>
<h3> Output</h3>
</u> </font>
<font size="2" face="Verdana">
X1 = ${distance2.x1} <br>
Y1 = ${distance2.y1} <br>
X2 = ${distance2.x2} <br>
Y2 = ${distance2.y2} <br>
</font>
<br>
<font size="3" face=Verdana" color="blue"> <b>
The distance between (X1, Y1) and (X2, Y2) is
<fmt:formatNumber value="${distance2.distanceBetweenPoints}"
type="number"
maxFractionDigits="2"/>
</c:when>
<c:otherwise>
rrz${distance2.status}rrz
</c:othewise>
</c:choose>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>>>I made a typo
Sorry I didn't catch that one. Now I am seeing the same thing: I have the page, I am able to input the values, I click the Calculate button, and nothing happens. The only difference I see is the following at the bottom of the page, below the Calculate button: rrz()rrz. This is displayed before I click the Calculate button the first time.
Sorry I didn't catch that one. Now I am seeing the same thing: I have the page, I am able to input the values, I click the Calculate button, and nothing happens. The only difference I see is the following at the bottom of the page, below the Calculate button: rrz()rrz. This is displayed before I click the Calculate button the first time.
ASKER
Is it something in the JavaBean? Are my setDistanceBetweenPoints( ) and calculateDistance( ) methods ok?
I guess I will try your web app in my Tomcat now.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, I have added the web.xml file you posted. I wonder why I do not get that error.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I run this I get the following error:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /distanceCalculator2.jsp(3,0) The value for the useBean class attribute calc.DistanceCalc2 is invalid.
ASKER
Nevermind, I have it working.
ASKER
What am I missing to display my output in the <c:choose> tag?
>What am I missing to display my output in the <c:choose> tag?
The output is displayed for me. What problem are you having with it ?
The output is displayed for me. What problem are you having with it ?
ASKER
I have most of it figured out now. I do have one more problem though.
With a call to calculateDistance( ); inside the getDistanceBetweenPoints( ) method, I am able to get a result for distanceBetweenPoints, but I am NOT able to check for user input.
Without a call to calculateDistance( ); inside the getDistanceBetweenPoints( ) method, I am able to check for user input, but I am NOT able to get a result for distanceBetweenPoints.
My most recent code is here:
With a call to calculateDistance( ); inside the getDistanceBetweenPoints( ) method, I am able to get a result for distanceBetweenPoints, but I am NOT able to check for user input.
Without a call to calculateDistance( ); inside the getDistanceBetweenPoints( ) method, I am able to check for user input, but I am NOT able to get a result for distanceBetweenPoints.
My most recent code is here:
// The JavaBean
// DistanceCalc2.java
package calc;
public class DistanceCalc2
{
// read-write properties
private String x1;
private String y1;
private String x2;
private String y2;
// read-only properties
private double distanceBetweenPoints;
// default constructor
//-----------------------------------------
public DistanceCalc2( )
{
}
//-----------------------------------------
// setter and getter methods
//-----------------------------------------
public void setX1( String passedX1 )
{
x1 = passedX1;
}
//-----------------------------------------
public String getX1( )
{
return x1;
}
//-----------------------------------------
public void setY1( String passedY1 )
{
y1 = passedY1;
}
//-----------------------------------------
public String getY1( )
{
return y1;
}
//-----------------------------------------
public void setX2( String passedX2 )
{
x2 = passedX2;
}
//-----------------------------------------
public String getX2( )
{
return x2;
}
//-----------------------------------------
public void setY2( String passedY2 )
{
y2 = passedY2;
}
//-----------------------------------------
public String getY2( )
{
return y2;
}
//-----------------------------------------
public void setDistanceBetweenPoints( )
{
calculateDistance( );
}
//-----------------------------------------
public double getDistanceBetweenPoints( )
{
//calculateDistance( );
return distanceBetweenPoints;
}
//-----------------------------------------
private void calculateDistance( )
{
distanceBetweenPoints = Math.sqrt( ( Double.parseDouble( x1 ) - Double.parseDouble( x2 ) ) *
( Double.parseDouble( x1 ) - Double.parseDouble( x2 ) ) +
( Double.parseDouble( y1 ) - Double.parseDouble( y2 ) ) *
( Double.parseDouble( y1 ) - Double.parseDouble( y2 ) ) );
}
}
<%-- distanceCalculator2.jsp --%>
<jsp:useBean id="distance2" scope="page" class="calc.DistanceCalc2" />
<jsp:setProperty name="distance2" property="*" />
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head><title>JSP Distance Calculator using EL Statements, JSTL, and a JavaBean</title> </head>
<body>
<font face="Verdana"><center><i>
<h1>JSP Distance Calculator using EL Statements, JSTL, and a JavaBean</h1>
</i></center></font>
<c:set var="x1" value="${distance2.x1}"/>
<c:set var="y1" value="${distance2.y1}"/>
<c:set var="x2" value="${distance2.x2}"/>
<c:set var="y2" value="${distance2.y2}"/>
<c:set var="distanceBetweenPoints" value="${distance2.distanceBetweenPoints}"/>
<form method="post" action="distanceCalculator2.jsp"/>
<br>
<font size="2" face="Verdana">
Please enter the value of X1:
<font color="blue">*</font>
<input type="text" name="x1" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of Y1:
<font color="blue">*</font>
<input type="text" name="y1" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of X2:
<font color="blue">*</font>
<input type="text" name="x2" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of Y2:
<font color="blue">*</font>
<input type="text" name="y2" length="7"/>
</font>
<p>
<input type="submit" value="Calculate"/>
</p>
</form>
<c:if test="${pageContext.request.method=='POST'}">
<c:choose>
<c:when test='${x1 == null}'>
<hr/><br/>
<font size="4" face=Verdana" color="red">
Please input a value for X1.
</font>
</c:when>
<c:when test='${y1 == null}'>
<hr/><br/>
<font size="4" face=Verdana" color="red">
Please input a value for Y1.
</font>
</c:when>
<c:when test='${x2 == null}'>
<hr/><br/>
<font size="4" face=Verdana" color="red">
Please input a value for X2.
</font>
</c:when>
<c:when test='${y2 == null}'>
<hr/><br/>
<font size="4" face=Verdana" color="red">
Please input a value for Y2.
</font>
</c:when>
<c:otherwise>
<hr/>
<font face="Verdana"> <u>
<h3>Output</h3>
</u></font>
<font size="4" face="Verdana" color="blue">
X1 = ${x1} <br/>
Y1 = ${y1} <br/>
X2 = ${x2} <br/>
Y2 = ${y2} <br/>
</font>
<br/><br/>
<font size="4" face="Verdana" color="blue">
The distance between (X1, Y1) and (X2, Y2) is
<fmt:formatNumber value="${distanceBetweenPoints}"
type="number" maxFractionDigits="15"/>
</font>
</c:otherwise>
</c:choose>
</c:if>
<font size="4" face="Verdana" color="green">
<br/>
<br/>
x1=${x1}
<br/>
y1=${y1}
<br/>
x2=${x2}
<br/>
y2=${y2}
<br/>
distanceBetweenPoints=${distanceBetweenPoints}
<br/>
</font>
</body>
</html>
ASKER
I got that part now. My getDistanceBetweenPoints( ) method now looks like this:
public double getDistanceBetweenPoints( )
{
if( ( x1 != null ) && ( y1 != null ) && ( x2 != null ) && ( y2 != null ) )
{
calculateDistance( );
}
return distanceBetweenPoints;
}
I know you recommended exception handling for letters being input. Where would I put the exception?
public double getDistanceBetweenPoints( )
{
if( ( x1 != null ) && ( y1 != null ) && ( x2 != null ) && ( y2 != null ) )
{
calculateDistance( );
}
return distanceBetweenPoints;
}
I know you recommended exception handling for letters being input. Where would I put the exception?
ASKER
Do I need to use the <%@ page errorPage> directive to handle the exception?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I did redesign. I got rid of the status variable altogether. Below is my latest code including my attempt at exception handling.
// The JavaBean
// DistanceCalc2.java
package calc;
public class DistanceCalc2
{
// read-write properties
private String x1;
private String y1;
private String x2;
private String y2;
// read-only properties
private double distanceBetweenPoints;
private String errorMessage;
// default constructor
//-----------------------------------------
public DistanceCalc2( )
{
}
//-----------------------------------------
// setter and getter methods
//-----------------------------------------
public void setX1( String passedX1 )
{
x1 = passedX1;
}
//-----------------------------------------
public String getX1( )
{
return x1;
}
//-----------------------------------------
public void setY1( String passedY1 )
{
y1 = passedY1;
}
//-----------------------------------------
public String getY1( )
{
return y1;
}
//-----------------------------------------
public void setX2( String passedX2 )
{
x2 = passedX2;
}
//-----------------------------------------
public String getX2( )
{
return x2;
}
//-----------------------------------------
public void setY2( String passedY2 )
{
y2 = passedY2;
}
//-----------------------------------------
public String getY2( )
{
return y2;
}
//-----------------------------------------
public void setDistanceBetweenPoints( )
{
calculateDistance( );
}
//-----------------------------------------
public double getDistanceBetweenPoints( )
{
if( ( x1 != null ) && ( y1 != null ) && ( x2 != null ) && ( y2 != null ) )
{
try
{
Double.parseDouble( x1 );
Double.parseDouble( y1 );
Double.parseDouble( x2 );
Double.parseDouble( y2 );
}
catch ( NumberFormatException nfe )
{
errorMessage = "Please enter a valid number: " + nfe.getMessage( );
setErrorMessage( errorMessage );
}
catch ( Exception e )
{
errorMessage = "An error occured: " + e.getMessage( );
setErrorMessage( errorMessage );
}
calculateDistance( );
}
return distanceBetweenPoints;
}
//-----------------------------------------
public void setErrorMessage( String passedErrorMessage )
{
errorMessage = passedErrorMessage;
}
//-----------------------------------------
public String getErrorMessage( )
{
return errorMessage;
}
//-----------------------------------------
private void calculateDistance( )
{
distanceBetweenPoints = Math.sqrt( ( Double.parseDouble( x1 ) - Double.parseDouble( x2 ) ) *
( Double.parseDouble( x1 ) - Double.parseDouble( x2 ) ) +
( Double.parseDouble( y1 ) - Double.parseDouble( y2 ) ) *
( Double.parseDouble( y1 ) - Double.parseDouble( y2 ) ) );
}
}
//===================================
//===================================
<%-- distanceCalculator2.jsp --%>
<jsp:useBean id="distance2" scope="page" class="calc.DistanceCalc2" />
<jsp:setProperty name="distance2" property="*" />
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head><title>JSP Distance Calculator using EL Statements, JSTL, and a JavaBean</title> </head>
<body>
<br/>
<font face="Verdana"><center><i>
<h2>JSP Distance Calculator using EL Statements, JSTL, and a JavaBean</h2>
</i></center></font>
<c:set var="x1" value="${distance2.x1}"/>
<c:set var="y1" value="${distance2.y1}"/>
<c:set var="x2" value="${distance2.x2}"/>
<c:set var="y2" value="${distance2.y2}"/>
<c:set var="distanceBetweenPoints" value="${distance2.distanceBetweenPoints}"/>
<c:set var="errorMessage" value="${distance2.errorMessage}"/>
<form method="post" action="distanceCalculator2.jsp">
<br>
<font size="2" face="Verdana">
Please enter the value of X1:
<font color="blue">*</font>
<input type="text" name="x1" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of Y1:
<font color="blue">*</font>
<input type="text" name="y1" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of X2:
<font color="blue">*</font>
<input type="text" name="x2" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of Y2.
<font color="blue">*</font>
<input type="text" name="y2" length="7"/>
</font>
<p>
<input type="submit" value="Calculate"/>
</p>
</form>
<c:if test="${pageContext.request.method=='POST'}">
<c:choose>
<c:when test='${x1 == null}'>
<hr/><br/>
<font size="4" face="Verdana" color="red">
You did not enter a value for X1.
</font>
</c:when>
<c:when test='${y1 == null}'>
<hr/><br/>
<font size="4" face="Verdana" color="red">
You did not enter a value for X1.
</font>
</c:when>
<c:when test='${x2 == null}'>
<hr/><br/>
<font size="4" face="Verdana" color="red">
You did not enter a value for X1.
</font>
</c:when>
<c:when test='${y2 == null}'>
<hr/><br/>
<font size="4" face="Verdana" color="red">
You did not enter a value for X1.
</font>
</c:when>
<c:otherwise>
<hr/>
<font face="Verdana"> <u>
<h3>Output</h3>
</u></font>
<font size="4" face="Verdana" color="blue">
X1 = ${x1} <br/>
Y1 = ${y1} <br/>
X2 = ${x2} <br/>
Y2 = ${y2} <br/>
</font>
<c:choose>
<c:when test='${errorMessage != null}'>
<br/>
<font size="4" face="Verdana" color="red">
${errorMessage}
</font>
</c:when>
<c:otherwise>
<br/>
<font size="4" face="Verdana" color="blue">
The distance between (X1, Y1) and (X2, Y2) is
<fmt:formatNumber value="${distanceBetweenPoints}"
type="number" maxFractionDigits="15"/>
</font>
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
</c:if>
<%--
<font size="4" face="Verdana" color="green">
<br/><br/>
x1=${x1}
<br/>
y1=${y1}
<br/>
x2=${x2}
<br/>
y2=${y2}
<br/>
distanceBetweenPoints=${distanceBetweenPoints}
<br/>
</font>
--%>
</body>
</html>
ASKER
OK, it works like a charm. Thank you very much for taking the time to help me. Below is the working code:
// The JavaBean
// DistanceCalc2.java
package calc;
public class DistanceCalc2
{
// read-write properties
private String x1;
private String y1;
private String x2;
private String y2;
// read-only properties
private double distanceBetweenPoints;
private int status = 0;
// default constructor
//-----------------------------------------
public DistanceCalc2( )
{
}
//-----------------------------------------
// setter and getter methods
//-----------------------------------------
public void setX1( String passedX1 )
{
x1 = passedX1;
}
//-----------------------------------------
public String getX1( )
{
return x1;
}
//-----------------------------------------
public void setY1( String passedY1 )
{
y1 = passedY1;
}
//-----------------------------------------
public String getY1( )
{
return y1;
}
//-----------------------------------------
public void setX2( String passedX2 )
{
x2 = passedX2;
}
//-----------------------------------------
public String getX2( )
{
return x2;
}
//-----------------------------------------
public void setY2( String passedY2 )
{
y2 = passedY2;
}
//-----------------------------------------
public String getY2( )
{
return y2;
}
//-----------------------------------------
public void setDistanceBetweenPoints( )
{
calculateDistance( );
}
//-----------------------------------------
public double getDistanceBetweenPoints( )
{
if( ( x1 != null ) && ( y1 != null ) && ( x2 != null ) && ( y2 != null ) )
{
try
{
calculateDistance( );
}
catch(NumberFormatException nfe)
{
status = 1;
}
}
return distanceBetweenPoints;
}
//-----------------------------------------
public int getStatus( )
{
return status;
}
//-----------------------------------------
private void calculateDistance( )
{
distanceBetweenPoints = Math.sqrt( ( Double.parseDouble( x1 ) - Double.parseDouble( x2 ) ) *
( Double.parseDouble( x1 ) - Double.parseDouble( x2 ) ) +
( Double.parseDouble( y1 ) - Double.parseDouble( y2 ) ) *
( Double.parseDouble( y1 ) - Double.parseDouble( y2 ) ) );
}
//-----------------------------------------
}
//=======================
//=======================
<%-- distanceCalculator2.jsp --%>
<jsp:useBean id="distance2" scope="page" class="calc.DistanceCalc2" />
<jsp:setProperty name="distance2" property="*" />
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head><title>JSP Distance Calculator using EL Statements, JSTL, and a JavaBean</title> </head>
<body>
<br/>
<font face="Verdana"><center><i>
<h2>JSP Distance Calculator using EL Statements, JSTL, and a JavaBean</h2>
</i></center></font>
<c:set var="x1" value="${distance2.x1}"/>
<c:set var="y1" value="${distance2.y1}"/>
<c:set var="x2" value="${distance2.x2}"/>
<c:set var="y2" value="${distance2.y2}"/>
<c:set var="distanceBetweenPoints" value="${distance2.distanceBetweenPoints}"/>
<c:set var="status" value="${distance2.status}"/>
<form method="post" action="distanceCalculator2.jsp">
<br>
<font size="2" face="Verdana">
Please enter the value of X1:
<font color="blue">*</font>
<input type="text" name="x1" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of Y1:
<font color="blue">*</font>
<input type="text" name="y1" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of X2:
<font color="blue">*</font>
<input type="text" name="x2" length="7"/>
<br>
</font>
<font size="2" face="Verdana">
Please enter the value of Y2.
<font color="blue">*</font>
<input type="text" name="y2" length="7"/>
</font>
<p>
<input type="submit" value="Calculate"/>
</p>
</form>
<c:if test="${pageContext.request.method=='POST'}">
<c:choose>
<c:when test="${status == 1}">
<hr/><br/>
<font size="4" face="Verdana" color="red">
Please input numbers only.
</font>
</c:when>
<c:when test='${x1 == null}'>
<hr/><br/>
<font size="4" face="Verdana" color="red">
You did not enter a value for X1.
</font>
</c:when>
<c:when test='${y1 == null}'>
<hr/><br/>
<font size="4" face="Verdana" color="red">
You did not enter a value for Y1.
</font>
</c:when>
<c:when test='${x2 == null}'>
<hr/><br/>
<font size="4" face="Verdana" color="red">
You did not enter a value for X2.
</font>
</c:when>
<c:when test='${y2 == null}'>
<hr/><br/>
<font size="4" face="Verdana" color="red">
You did not enter a value for Y2.
</font>
</c:when>
<c:otherwise>
<hr/>
<font face="Verdana"> <u>
<h3>Output</h3>
</u></font>
<font size="4" face="Verdana" color="blue">
X1 = ${x1} <br/>
Y1 = ${y1} <br/>
X2 = ${x2} <br/>
Y2 = ${y2} <br/>
</font>
<br/>
<font size="4" face="Verdana" color="blue">
The distance between (X1, Y1) and (X2, Y2) is
<fmt:formatNumber value="${distanceBetweenPoints}"
type="number" maxFractionDigits="15"/>
</font>
</c:otherwise>
</c:choose>
</c:if>
<%--
<font size="4" face="Verdana" color="green">
<br/><br/>
x1=${x1}
<br/>
y1=${y1}
<br/>
x2=${x2}
<br/>
y2=${y2}
<br/>
distanceBetweenPoints=${distanceBetweenPoints}
<br/>
</font>
--%>
</body>
</html>
ASKER
Thanks again for the superior assistance!
ASKER
Open in new window
DistanceCalculator2.zip