在问大家一个问题!!! 500 Servlet Exception java.lang.NullPointerException at java.io.File.<init>(File.java:180) at _programe._uploadfile._upload__jsp._jspService (/programe/uploadFile/upload.jsp:47) at com.caucho.jsp.JavaPage.service(JavaPage.java:75) 这样的异常怎么解决???由什么引起的,应该怎么着手解决??? 我用的是resin,请各位帮忙了!!!!
各位帮忙看一下: 第一个页面的代码:upload1.jsp<%@ page contentType="text/html; charset=gb2312" import="java.util.Date ,java.io.*,java.lang.*,java.text.SimpleDateFormat"%> <HTML> <BODY BGCOLOR="white"><H1 align="center">图片、电影、音乐、新闻上传</H1> <HR><FORM METHOD="POST" ACTION="/programe/uploadFile/upload.jsp" ENCTYPE="multipart/form-data"> <select name="Type" size="1" > //*****这是要传送的值“Type"******** <%String path="";path = request.getRealPath("./");File d = new File(path); //建立代表目前目录位置的File件, 并由d件变数引用File list[] = d.listFiles(); //取得代表目录中所有文件的File件阵列 int j=list.length-3; int i =0; while(j>0) {%> <option value="<%=list[i]%>"><%=list[i]%></option> <% i++; j--; } %> </select> <select name="Year" size="1"> <% Date today = new Date(); SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); String sToday = format.format(today); int lToday = Integer.parseInt(sToday); int w = lToday%10000; int ww=(lToday-w)/10000;
// Save the files with their original names in a virtual path of the web server try { count = mySmartUpload.save(filePath, mySmartUpload.SAVE_VIRTUAL);
请上面的两位:javahui(阶级斗争要年年讲,月月讲,天天讲。) ,star821116(业精于勤荒于嬉,行成于思毁于随) 帮忙看一下这个帖,“m_currentIndex”怎么的到当前字节数组的指针位置???
帮忙啦!!!!
至于你说的那篇文章里面的m_currentIndex,我看就是一个整数(用于指明位置),初始化的位置一般应当是0。
刚才试图得到数组的首地址,未果
500 Servlet Exception
java.lang.NullPointerException
at java.io.File.<init>(File.java:180)
at _programe._uploadfile._upload__jsp._jspService (/programe/uploadFile/upload.jsp:47)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
这样的异常怎么解决???由什么引起的,应该怎么着手解决???
我用的是resin,请各位帮忙了!!!!
第一个页面的代码:upload1.jsp<%@ page contentType="text/html; charset=gb2312"
import="java.util.Date ,java.io.*,java.lang.*,java.text.SimpleDateFormat"%>
<HTML>
<BODY BGCOLOR="white"><H1 align="center">图片、电影、音乐、新闻上传</H1>
<HR><FORM METHOD="POST" ACTION="/programe/uploadFile/upload.jsp" ENCTYPE="multipart/form-data">
<select name="Type" size="1" > //*****这是要传送的值“Type"********
<%String path="";path = request.getRealPath("./");File d = new File(path);
//建立代表目前目录位置的File件, 并由d件变数引用File list[] = d.listFiles();
//取得代表目录中所有文件的File件阵列
int j=list.length-3;
int i =0;
while(j>0)
{%>
<option value="<%=list[i]%>"><%=list[i]%></option>
<%
i++;
j--;
}
%>
</select>
<select name="Year" size="1">
<%
Date today = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String sToday = format.format(today);
int lToday = Integer.parseInt(sToday);
int w = lToday%10000;
int ww=(lToday-w)/10000;
%>
<option value="<%=String.valueOf(ww)%>"><%=String.valueOf( ww)%></option>
</select>
<select name="Month" size="1">
<%
for(int month=1;month<=12;month++)
{
%>
<option value="<%=String.valueOf(month)%>"><%=String.valueOf( month)%></option>
<%
}
%>
</select>
<select name="Day" size="1">
<%
for(int day=1;day<=31;day++)
{
%>
<option value="<%=String.valueOf(day)%>"><%=String.valueOf(day)%></option>
<%
}
%>
</select>
<br>
<INPUT TYPE="FILE" NAME="FILE1" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE2" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE3" SIZE="50"><BR>
<INPUT TYPE="FILE" NAME="FILE4" SIZE="50"><BR>
<INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM></BODY>
</HTML>第二个页面的代码:upload.jsp
<%@ page contentType="text/html; charset=gb2312" language="java"
import="com.jspsmart.upload.*,java.io.File,java.lang.*,java.util.Date,java.text.SimpleDateFormat"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<HTML>
<head>
<title>Images,Movies,Music,News UpLoaded</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><BODY BGCOLOR="white"><H1 align="center">Images,Movies,Music,News UpLoaded</H1>
<HR><%String type = request.getParameter("Type"); //********这是接收这个传送的值******
//String year = request.getParameter("Year");
//String month =request.getParameter("Month");
//String day = request.getParameter("Day");
out.println(type);String path="";path = request.getRealPath("./");File d = new File(path);
//建立代表目前目录位置的File件, 并由d件变数引用File list[] = d.listFiles();
//取得代表目录中所有文件的File件阵列
%><%
// Variables
int count=0; // Initialization
mySmartUpload.initialize(pageContext); // Only allow txt or htm files
mySmartUpload.setAllowedFilesList(" gif,jpg,swf,txt"); // DeniedFilesList can also be used :
// mySmartUpload.setDeniedFilesList("exe,bat,jsp"); // Deny physical path
// mySmartUpload.setDenyPhysicalPath(true); // Only allow files smaller than 2000000 bytes
mySmartUpload.setMaxFileSize(2000000); // Deny upload if the total fila size is greater than 800000 bytes
mySmartUpload.setTotalMaxFileSize(800000); // Upload
mySmartUpload.upload();
//look for file path ,if there is nothing ,create file path
File myFilePath = new File(type);
if(!myFilePath.exists())
myFilePath.mkdir();
String nextFilePath="";
nextFilePath = request.getRealPath("myFilePath/");
Date today = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String sToday = format.format(today);
String fileName =sToday;
File myFile = new File(nextFilePath+"/"+fileName);
if(!myFile.exists())
myFile.mkdir();
String filePath = nextFilePath+"/"+fileName;
// Save the files with their original names in a virtual path of the web server
try { count = mySmartUpload.save(filePath, mySmartUpload.SAVE_VIRTUAL);
} catch (Exception e){ out.println("<b>Wrong selection : </b>" + e.toString()); }
// Display the number of files uploaded
out.println(count + " file(s) uploaded.");%>
<table width="85%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td colspan="8">在<Font color = red><%= path%></Font>目录下的文件 一共有 <font color="#FF0000"><%=list.length%></font>
个文件或目录 <a href="javascript:history.back(1)">返回</a> <a href="javascript:location.reload()">刷新</a> </td>
</tr>
</table>
<hr>
<table width="1000" height="150"border="0" align="center" cellpadding="3" cellspacing="0">
<%
for(int i=0; i <list.length/5; i++)
{
%>
<tr >
<%
for(int j=0;j<5;j++)
{
File f = new File(path,list[i*5+j].getName());
String file="";
file=list[i*5+j].getName();//out.print(file.toString());
%>
<td align="center" width="120" height="150">
<a href="<%=file%>" target="_self"><img src="<%=file%>" width="120" height="150" name="<%=file.toString()%>" title="<%=file.toString()%>" ></a>
<a href="<%=file%>" target="_parent"><%=file%></a>
</td>
<%
}
%>
</tr>
<%
}
%>
</table>
<BR>
<a href="javascript:history.back(1)">Back</a>
</BODY>
</HTML>
大家帮忙看看为什么传过来的值接收后为空????在线等!!!!急啊!!!!!!!!!!!!