Jsp页面传递文件信息
jsp中采用文件流实现文件上传,得到上传的文件的内容:
in = new DataInputStream(request.getInputStream()); //读入上传的数据
int formDataLength = request.getContentLength();
if(formDataLength > MAX_SIZE){
out.println("<P>上传的文件字节数不可以超过" + MAX_SIZE + "</p>");
return;
}
byte dataBytes[] = new byte[formDataLength]; //保存上传文件的数据
int byteRead = 0;
int totalBytesRead = 0;
while(totalBytesRead < formDataLength){ //上传的数据保存在byte数组
byteRead = in.read(dataBytes,totalBytesRead,formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes); //根据byte数组创建字符串
将文件的内容转换成字符串file之后,现在想在不同的页面上传递这个file,可是在另一个页面上得到这个值后,再输出,却只有部分内容,很少的东西
试过各种方法:I.用<a href="index.jsp?file="+file+""></a>,不行
II.用form表单:a.<input type="file" name="file" value=<%=?%>>,不行
b.<input type="text" name="file" value=<%=?%>>,不行
c.<input
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
问题是这样的:
我有一个文件nagiv.jsp 另一个文件failure.jsp包含他,同时nagiv文件中有一个可以跳转到yy.jsp的commandButton,但是我将failure中点击nagiv中的哪个commandButton,也面不会跳转 ......
我是个新手,做一个JSP网页,我要读出数据库正常,但是我要修改的时候,也就是读入的时候出现乱码,请高手告诉我怎么解决,先谢谢了。
request.setCharacterEncoding("UTF-8");
把编码统一
/**
......
在jsp页面中怎么获得Struts2在action中配置的request。
我在后台的配置如下:
List list = new ArrayList();
list.add(users);
ActionContext ct= ActionContext.getContext();
HttpServletRequest requ ......
这是错误信息,严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 33 in the jsp file: /WebRo ......