请问如果我做了这样的一个类,怎么做一个环境进行验证呢? 希望解答详细一点:) 谢谢/**
* Login error class
*
* @autor zgh
* @version 1.0 2005/07/14
* @since JDK1.4.2
*/
public class LoginException{
/**
* @param string
* @return
*/
   private static Object Redirect(String string) {
      return null;
}
/**
* <pre>验证登陆名字密码,完成验证后,跳转到display.jsp页面</pre>

* @param args.
* @return the desired character.
*/public static void main(String[] args) {  
/**登陆名字*/          
       String strName = new String();
/**登陆密码*/ 
       String strThing = new String();
/**接收输入登陆名字密码*/
try { 
    strName = Request.getParameter("name"); 
   strThing = Request.getParameter("thing"); 
/**当遇到输入名字为空或者超出原定长度时抛出异常*/
if ((strName == null) || (strName.length() == 0) || (strName.length() >= 10 )) { 
throw new Exception("null strName"); 

/**当遇到输入密码为空或者超出原定长度时抛出异常*/
if ((strThing == null) || (strThing.length()==0) || (strThing.length() >= 10 )) 
throw new Exception("null strThing");  
/**抛出异常后跳转到display.jsp页面*/
response.sendRedirect ("display.jsp"); 
} catch (Exception e) { 

}
}

解决方案 »

  1.   

    测试web/servlet的话,试试用httpunit吧,这个东东可以模拟浏览器的动作,完成提交登录操作!
      

  2.   

    改写成JSP呗
    环境能够支持jsp就成
      

  3.   

    写个servlet吧,楼主你这么写肯定不行的。
      

  4.   

    不清楚楼主所谓的获得一个“环境”进行测试是什么意思?
    是期望获得一组相关的测试用例?
    是希望知道使用什么测试工具(诸如JUNIT)?
    or ...?@.@||~
      

  5.   

    我是说怎么可以看到这个代码应用到其他的程序中去也是成功的呢?
    或者写一个servlet怎么写呢? 写好了又怎么用呢?是这意思 
    本人初次学习java 实在是蔡鸟一个 希望大家说的详细,详细!
    很多概念也不是很清楚 请指教。
      

  6.   

    至于工具测试的话比如junit我知道一点 但是它是一个单元测试的工具
    我希望是看到这个class可以用到一个程序中取得效果
    比如在一个login叶面上 登陆时的报错