//上传图片页面
<body>
  
  <% String name=(String)session.getAttribute("Name");
     if(name==null)
       {name="";
       }
   out.print("<image src=http://192.168.1.100:8080/examples/"+name);
%></body>
//接收图片页面
<head>
<base href="<%=basePath%>"> <title>My JSP 'accept.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head> <body>
<%
try { 
//用客户的session的id建立一个临时文件:
String tempFileName = (String) session.getId();
//建立临时文件f1:
File f1 = new File("E:/S2文件/JSP/", tempFileName);
FileOutputStream o = new FileOutputStream(f1);
//将客户上传的全部信息存入f1:
InputStream in = request.getInputStream();
byte b[] = new byte[10000];
int n;
while ((n = in.read(b)) != -1) {
o.write(b, 0, n);
}
o.close();
in.close();
//读取临时文件f1,从中获取上传文件的名字,和上传的文件的内容:
RandomAccessFile random = new RandomAccessFile(f1, "r");
//读出f1的第2行,析取出上传文件的名字:
int second = 1;
String secondLine = null;
while (second <= 2) {
secondLine = random.readLine();
second++;
}
//获取第2行中目录符号'\'最后出现的位置
int position = secondLine.lastIndexOf('\\');
//客户上传的文件的名字是:
String fileName = secondLine.substring(position + 1, secondLine
.length() - 1);
random.seek(0); //再定位到文件f1的开头。
//获取第4行回车符号的位置: 
long forthEndPosition = 0;
int forth = 1;
while ((n = random.readByte()) != -1 && (forth <= 4)) {
if (n == '\n') {
forthEndPosition = random.getFilePointer();
forth++;
}
}
//根据客户上传文件的名字,将该文件存入磁盘:
File f2 = new File("E:/S2文件/JSP/", fileName);
session.setAttribute("Name", fileName);//供showImage.jsp页面使用。
RandomAccessFile random2 = new RandomAccessFile(f2, "rw");
//确定出文件f1中包含客户上传的文件的内容的最后位置,即倒数第6行。
random.seek(random.length());
long endPosition = random.getFilePointer();
long  = endPosition;
int j = 1;
while (( >= 0) && (j <= 6)) {
--;
random.seek();
n = random.readByte();
if (n == '\n') {
endPosition = random.getFilePointer();
j++;
}
}
//将random流指向文件f1的第4行结束的位置:
random.seek(forthEndPosition);
long startPoint = random.getFilePointer();
//从f1读出客户上传的文件存入f2(读取从第4行结束位置和倒数第6行之间的内容)。
while (startPoint < endPosition - 1) {
n = random.readByte();
random2.write(n);
startPoint = random.getFilePointer();
}
random2.close();
random.close();
f1.delete(); //删除临时文件
} catch (IOException ee) {
}
out.print("文件已上传");
%>
<P>
查看上传的图象效果
<%
String str = response.encodeURL("showImage.jsp");
%>

<FORM action="<%=str%>">
<Input type=submit value="查看">
</FOrm> </body>
//图片显示页面</head>
  
  <body>
  
  <% String name=(String)session.getAttribute("Name");
     if(name==null)
       {name="";
       }
   out.print("<image src=E:/S2文件/JSP/"+name);
%>  </body>
为什么我在服务器上上传了图片,而在图片显示页面却看不到上传的图片呢,但要是回到"E:/S2文件/JSP/"目录下去查看图片的话。图片确实是上传到了该目录下,问题就在于图片显示页面中“name”的值都能打印出来,但就是看不到上传的图片。哪位朋友帮我看下,大概问题是出在“E:/S2文件/JSP/”这里吧,可自己试了好半天还是一无所获。在这里先说声谢谢了。