Hello everybody,
As i m beginner to Jsp/Servlet..
I want to Upload a image from client side and store it in MySql database then simultaneously display it.
I need it urgently can anybody send me the code.......
Please,.....
Thanks
Hello everybody,
As i m beginner to Jsp/Servlet..
I want to Upload a image from client side and store it in MySql database then simultaneously display it.
I need it urgently can anybody send me the code.......
Please,.....
Thanks
Thanks....but i hav tried that...and failed..
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.*;
I have the above code errors....
I m using tomcat 5.5...can u plz help me in resolving that..
Thank you very much....errors are cleaned...
I will try for the code if any problem in future i need ur help..plz..
Thanks a lot
<%
String contentType = request.getContentType();
System.out.println("Content type is :: " +contentType);
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);
String saveFile = file.substring(file.indexOf("filename=\"") + 10);
//out.print("FileName:" + saveFile.toString());
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
//out.print("FileName:" + saveFile.toString());
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
//out.println(boundary);
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 = "C:\\apache-tomcat-6.0.29\\webapps\\ROOT\\Extrusions\\" + saveFile;
FileOutputStream fileOut = new FileOutputStream(saveFile);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
out.println("File saved as " +saveFile);
}
rs.close();
stmt.close();
con.close();
%>
Hi Everyone, i am new to webservice,i need to call webservice from client machine,i dont know the steps what to do,pls guide me ,pls send me a sample code to call the methods of webserver from my client machine.waiting for u r replay
regards,
<EMAIL SNIPPED>
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.