Filename-error.jsp
<html>
<body>
<form action="http://localhost:8090/wtad/def35/pagedirective.jsp">
no1
<input type="text"
name="no1" />
<br>
no2
<input type="text"
name="no2" />
<br>
<input type="submit"
/>
</form>
</body>
</html>
Filename-pagedirective.jsp
<html>
<body>
<%@ page contentType="text/html"
import="java.util.*,def35.MYMath"
session="true" buffer="none"
errorPage="error_ex.jsp" %>
<%
session.setAttribute("istar","istar123"); %>
<hr>
<% int
no1=Integer.parseInt(request.getParameter("no1"));
int
no2=Integer.parseInt(request.getParameter("no2"));
%>
<br>
<h2>
division number=
<%= no1/no2 %>
</h2>
<br>
Square of number <b>25 is
<b> <%= MYMath.square(25) %>
<br>
<table border="2">
<tr>
<th>Id</th>
<th>Name</th>
<th>Cell_no</th>
</tr>
<tr>
<td>1</td>
<td>ABC</td>
<td>1234567879</td>
</tr>
<tr>
<td>2</td>
<td>BBC</td>
<td>1234567879</td>
</tr>
<tr>
<td>3</td>
<td>CCD</td>
<td>1234567879</td>
</tr>
</table>
<hr>
<br>
<%= new Date() %>
</body>
</html>
Filename-MyMath.java
package def35;
public class MYMath
{
public
static void main(String args[])
{
int
no=25;
System.out.println("Square
no is="+no+"is"+square(no));
}
public
static int square(int no)
{
return
no*no;
}
}
Filename-error.jsp
<html>
<body>
<form action="http://localhost:8090/wtad/def35/pagedirective.jsp">
no1
<input type="text"
name="no1" />
<br>
no2
<input type="text"
name="no2" />
<br>
<input type="submit"
/>
</form>
</body>
</html>
Output
no1
no2
no2
division
number= 10
Square of number 25 is 625
Id
|
Name
|
Cell_no
|
1
|
ABC
|
1234567879
|
2
|
BBC
|
1234567879
|
3
|
CCD
|
1234567879
|
Tue Apr 10 23:47:05 IST 2012
Exception Throws
java.lang.NumberFormatException: For input string: "ee"
No comments:
Post a Comment