在同一页面中显示成功的消息

时间:2014-01-08 14:51:36

标签: html jsp

我想在同一页面显示我的成功消息。我可以在同一页面显示成功消息。当我尝试它是gng到另一个页面..你可以编辑dat cod en帮我......

            <%@ page import="java.io.*"%>
       <%      String saveFile = "";   
         String contentType = request.getContentType();  
            if ((contentType != null) && (contentType.indexOf 
          ("multipart/form-data") >= 0))                {        
DataInputStream in = new DataInputStream(request.getInputStream());     
int formDataLength = request.getContentLength();        
byte dataBytes[] = new byte[formDataLength];       
int byteRead = 0;        
int totalBytesRead = 0;       
while (totalBytesRead < formDataLength) {       
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);            
totalBytesRead += byteRead;           
}           
String file = new String(dataBytes);        
saveFile = file.substring(file.indexOf("filename=\"") + 10);       
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));           
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,  
       saveFile.indexOf("\""));       
int lastIndex = contentType.lastIndexOf("=");           
String boundary = contentType.substring(lastIndex + 1, contentType.length());          
int pos;           
pos = file.indexOf("filename=\"");           
pos = file.indexOf("\n", pos) + 1;         
pos = file.indexOf("\n", pos) + 1;          
pos = file.indexOf("\n", pos) + 1;          
int boundaryLocation = file.indexOf(boundary, pos) - 4;     
int startPos = ((file.substring(0, pos)).getBytes()).length;          
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;          
saveFile = "D:/CETAF/Configuration Repository/Configuration/" + saveFile;         
File ff = new File(saveFile);          
FileOutputStream fileOut = new FileOutputStream(ff);          
fileOut.write(dataBytes, startPos, (endPos - startPos));           
fileOut.flush();            
fileOut.close();%><Br><table border="2">
           <tr>         
     <td><b>You have successfully upload the file by the name of:</b>         
        <%                  
        out.println(saveFile);                 
        }        
          %>          
         </td>      
          </tr>
         </table>

1 个答案:

答案 0 :(得分:0)

在此处保存一个会话变量,说&#34;成功&#34;将其命名为此操作的特定内容,重定向回上一页,在那里读取会话变量并显示成功消息,然后将该会话变量设置为null。

相关问题