真诚请教一个jsp中调用java程序的问题~,谢谢~
我在C:\test\hour14下面写了两个java程序
一个是InvalidUserNameException.java,代码如下
package test.hour14;
import
java.lang.Exception;
public class InvalidUserNameException extends Exception
{
public InvalidUserNameException(String message){
super(message);
}
}
一个是InvalidPasswordException.java,代码如下:
package test.hour14;
import java.lang.Exception;
public class InvalidPasswordException extends Exception
{
public InvalidPasswordException(String message){
super(message);
}
}
编译通过~~,
然后在C:\test\hour14\Raising下写了一个RaisingExceptionInClass.java,代码如下:
package test.hour14.Raising;
import test.hour14.*;
public class RaisingExceptionInClass
{
public RaisingExceptionInClass(){}
public void checkUsername(String username) throws InvalidUserNameException{
if(username.length() <4)
throw new InvalidUserNameException( "The username "+username+ " is too short ");
}
public void checkPassword(String password) throws InvalidPasswordException{
if(password.length() <4)
throw new InvalidPasswordException( "The password "+password+ " is too short ");
}
}
编译通过~,我用的是tomcat4.1,
于是将这个目录考到了C:\Program Files\Apache Group\Tomcat 4.1\webapps\myapp\WEB-INF\classes\下,
接着写了一个raisingExceptionInClass.jsp放在C:\Program Files\Apache Group\Tomcat 4.1\webapps\myapp\下边,代码如下:
<HTML>
<HEAD> <TITLE> </TITLE> </HEAD>
<BODY>
<%@ page import= "test.hour14.* "%>
<jsp:useBean id= "validate "
class= "test.hour14.raising.RaisingExceptionInClass "/>
<%
String username=request.getParameter( "username ");
String password=request.getParameter( "password ");
try{
if(username!=null) validate.checkUsername(username);
}catch(InvalidUsernameException e){%>
Sorry but your username <B> <%=username%> </B> is too short <BR>
<% }
try{
if(password!=null)validate.checkPassword(password);
}catch(InvalidPasswordException e){%>
Sorry but you password <B> <%=password%> </B> is too short <BR>
<% }%>
Please Login:
<FORM ACTION=raisingExceptionInClass.jsp METHOD=POST>
Username: <INPUT TYPE= "text " NAME= "username "> <BR>
Password: <INPUT TYPE= "text " NAME= "password "> <BR>
<INPUT TYPE= "submit " VALUE=Login>
</FORM>
</BODY>
</HTML> ,
但是我通过htt://localhost:8080/myapp/raisingExceptionInClass.jsp打开时,
提示说找不到test.hour14.raising这个软件包,请问一下各位,这是怎么回是?
------解决方案--------------------classpath设置了哇?
------解决方案-------------------- <%@page import=