بعد عمل صفحة تحميل للصورة من جهاز العميل الى السيرفر عند تجربة البرنامج كانت تعمل ولكن لان لا اعرف ما المشكلة الكود كما هو برجاء الرد لمعرفة السبب عند الضغط على زر التحميل لا يستجيب لاى شئ مع ان كان يعمل ما هو السبب
مع العلم انى الجار الموجودة تحت مجلد lib
tomahawk-1.1.5.jar
tomahawk.jar
myfaces-extensions-1.0.9.jar
commons-fileupload-1.2.2.jar
commons-io-1.1.jar
commons-logging-api-1.0.2.jar
commons-beanutils-1.7.0-osgi.jar
commons-io-1.1.jar
دى ال web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>loan</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<filter>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<display-name>extensionsFilter</display-name>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>
</filter>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>الصفحة
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
<title>t:inputFileUpload example</title>
</head>
<body dir="rtl">
<f:view>
<br/>
<br/><h1>تحميل صورة ضوئية من الغرض من القرض</h1>
<br/>
<center>
<h:form id="welcomeForm" enctype="multipart/form-data">
<table>
<tr><td><h:outputText value="رقم الطلب"/></td><td> <h:outputText value="#{loan.stu_num}"></h:outputText>
</td></tr>
<tr><td><h:outputText value="اسم الطالب"></h:outputText></td>
<td><h:outputText value="#{loan.stu_name}" /></td></tr>
</table>
<t:inputFileUpload id="fileupload" value="#{loan.upFile}"
size="20" style="width:500px" /><p/>
<h:commandButton value="تحميل" action="#{loan.upload2}" />
<h:commandButton value="عودة" action="Back_loan" />
</h:form>
</center>
</f:view>
</body>
</html>وده الكود الخاص بتحميل
public String upload2(){
try {
InputStream stream = upFile.getInputStream();
long size = upFile.getSize();
byte [] buffer = new byte[(int)size];
stream.read(buffer, 0, (int)size);
BufferedWriter cre_file = new BufferedWriter(new FileWriter("D:/UploadedFiles/fd"));
for(int str=0 ; str>buffer.length;str++){
cre_file.write(buffer[str]);
}
String file_num=getfilename();
//JOptionPane.showMessageDialog(null,file_num);
String ext=getExtension(upFile);
File FileSave= new File("D:/loan/WebContent/FileuploadForm/" + file_num + "." + ext);
OutputStream out = new FileOutputStream(FileSave);
boolean b=getexist(req_num,10);
boolean sub=getexist(Integer.parseInt(this.stu_num),10);
// boolean s=getexist(Integer.parseInt(stu_num) ,10);
InputStream in = new BufferedInputStream(upFile.getInputStream());
buffer = new byte[64 * 1024];
int count;
while ((count = in.read(buffer)) > 0){
out.write(buffer, 0, count);
}
in.close();
out.close();
try {
// Connection conn;
// conn =DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver "
// + "(*.mdb)}; Dbq=D:\\Stdnt.mdb");
conn_db();
if(b){
PreparedStatement pra_up=conn.prepareStatement("update atta set atta=? where re_no=? and type_ph=?");
pra_up.setString(1,"/FileuploadForm/"+ file_num + "." + ext );
pra_up.setInt(2,req_num);
pra_up.setInt(3, 10);
int msg_no = JOptionPane.showConfirmDialog(null, "سوف يتم تغير الفاتورة", "أنتبه", JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE);
if(msg_no==JOptionPane.YES_OPTION){
Killfile(req_num,10);
int msg= pra_up.executeUpdate();
if (msg==1){
JOptionPane.showMessageDialog(null,"تم تغير");
}
}
}else if(sub){
PreparedStatement pra_up=conn.prepareStatement("update atta set atta=? where re_no=? and type_ph=?");
pra_up.setString(1,"/FileuploadForm/"+ file_num + "." + ext );
pra_up.setInt(2,Integer.parseInt(stu_num));
pra_up.setInt(3, 10);
int msg_no = JOptionPane.showConfirmDialog(null, "سوف يتم تغير الفاتورة", "أنتبه", JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE);
if(msg_no==JOptionPane.YES_OPTION){
Killfile(Integer.parseInt(stu_num),10);
int msg= pra_up.executeUpdate();
if (msg==1){
JOptionPane.showMessageDialog(null,"تم تغير");
}
}
}else{
PreparedStatement prst=conn.prepareStatement("insert into atta(re_no,atta,type_ph)values(?,?,?)");
if(req_num==0){
prst.setInt(1,Integer.parseInt(stu_num));
}else{
prst.setInt(1, req_num);
}
prst.setString(2,"/FileuploadForm/"+ file_num + "." + ext );
prst.setString(3, "10");
JOptionPane.showMessageDialog(null, "form hear");
int stat=prst.executeUpdate();
if(stat==1){
JOptionPane.showMessageDialog(null, "تم عملية التحميل");
file1=true;
sub_req=false;
}
}
// PreparedStatement prst=conn.prepareStatement("insert into atta(re_no,atta)values(?,?,?)");
// prst.setString(1, String.valueOf(form_num));
// prst.setString(2,"/FileuploadForm/"+ file_num + "." + ext );
// prst.setString(3, "1");
// int stat=prst.executeUpdate();
// if(stat==1){
// JOptionPane.showMessageDialog(null, "تم عملية التحميل");
// }
}catch (SQLException e3) {
JOptionPane.showMessageDialog(null, "error");
}