2015-04-05 79 views
0

我的实际代码:请求调度

String input = "ECE&&non teaching staffs.*"; 
try{ 
    FileInputStream fstream = new FileInputStream("data1.txt"); 
    DataInputStream in = new DataInputStream(fstream); 
    BufferedReader br = new BufferedReader(new InputStreamReader(in)); 
    String strLine; 
    while ((strLine = br.readLine()) != null) { 
     if(Pattern.matches(in Pattern pattern = Pattern.compile("'put,strLine)){(.*?)'"); 
      Matcher mt = pattern.matcher(strLine); 
     while (mt.find()) { 
      String b=mt.group(1); 
      request.setAttribute("a",a); 
      String c=b.toString()+".*"; 
      FileInputStream fsstream = new FileInputStream("data1.txt"); 
      DataInputStream inn = new DataInputStream(fsstream); 
      BufferedReader bfr = new BufferedReader(new InputStreamReader(inn)); 
      String stringLine; 
      while ((stringLine = bfr.readLine()) != null) { 
       if(Pattern.matches(c,stringLine)){ 
        Pattern pat = Pattern.compile("#(.*?)#"); 
        Matcher mat = pat.matcher(stringLine); 
        while (mat.find()) { 
         String g=mat.group(1); 
         request.setAttribute("a",a); 
        } 
       } 
      } 
     } 
    } 
} 
} 
catch(Exception e){ 
    System.err.println("Error: " + e.getMessage()); 
} 

如何使用请求调度器在servlet while循环一样

while(...) 
{ 
    String a="anything"; 
    request.setAttribute("a",a); 

    while(...) 
    { 
     String b="anything else"; 
     request.setAttribute("a",a); 
    } 

    request.getRequestDispatcher("/output.jsp").forward(request, response); 
} 

在这种情况下,它只是提供了一个打印使用一些值价值和while作品只有一次 究竟放在哪里请求调度,使while环路工程和是否使用forward(...)与否?请帮忙 !

+0

什么时候继续的条件? – Razib 2015-04-05 16:13:26

+0

其实我刚刚给出了一个演示代码,在我的实际代码中while循环包含FileRead的条件,因为我正在从文本文件中读取值----- while((strLine = br.readLine()))! = null){..}请求调度程序如何创建问题为什么一会儿不工作? – 2015-04-05 16:18:57

+0

从你的帖子看来,while循环中的条件可能有问题。现在,你的评论似乎你正在尝试阅读一个文本文件。你的文本文件只包含一行吗? – Razib 2015-04-05 16:24:23

回答

0

使用的.forward它完全带走了Servlet的控制,并将其转发到另一个JSP页面,但我们可以用它.INCLUDE停留在当前的servlet才刚刚包括任何需要的地方所需要的JSP页面。