i hve used upload bean for uploading files...
im using netbeans and while compiling its says javazoom package does not exist...
any solutions ??
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
Obviously you missing download4j.jar that should be inside lib folder on your server
Next time please provide full info and not expect us to search for what ever you trying to do...
britto 0 Junior Poster in Training
thnx nw i can upload a file...
but when i send a value from html page to jsp page and print it
it displays null
whts the problem...
songname=request.getParameter("name");
this is hw i get the value from html page....
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
You should support your problems with relevant coding samples...
britto 0 Junior Poster in Training
this my jsp file..
<%@page contentType="text/html" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%
String saveFile = "",album="",location="",songname="";
String contentType = request.getContentType();
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);
songname=request.getParameter("name");
album=request.getParameter("album");
saveFile = file.substring(file.indexOf("filename=\"") + 10);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") +
1,saveFile.indexOf("\""));
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
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;
String folder = "F:/games/";
FileOutputStream fileOut = new FileOutputStream(folder + saveFile);
out.print("Saved here: " + saveFile);
//fileOut.write(dataBytes);
location=folder+saveFile;
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con=DriverManager.getConnection("jdbc:derby://localhost:1527/Xonicmp3","Xonic","Xonic");
ResultSet rs=null;
Statement stmt=con.createStatement();
String sql=("insert into "+album+" values('"+songname+"','"+saveFile+"','"+location+"')");
stmt.executeUpdate(sql);
rs.close();
con.close();
}catch(Exception e)
{
out.println(e.toString());
}
out.println(location);
out.println(album);
out.println(songname);
out.println(saveFile);
out.println(location);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
//out.println("Uploading your file. Please wait...");
}
%>
html file is
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Upload</title>
<style type="text/css">
.style1 {
font-size: 18pt;
color: #666666;
font-family: "Harlow Solid Italic";
}
.style2 {
font-family: Calibri;
}
</style>
</head>
<body bgcolor="black">
<form method="post" name="upform" enctype="multipart/form-data" action="fileUpload.jsp">
<table align="center">
<tr>
<td height="1000" width="800" background="up.jpg">
<div style="position: absolute; width: 482px; height: 392px; z-index: 1; left: 343px; top: 429px" id="layer1">
<div style="position: absolute; width: 231px; height: 24px; z-index: 7; left: 212px; top: 197px" id="layer8">
<select name="album">
<option>Akon</option>
<option>Ashlee Simpson</option>
<option>Avril</option>
<option>Backstreet Boys</option>
<option>Blue</option>
<option>Britney Spears</option>
<option>Hilarry Duff</option>
<option>Linkin Park</option>
<option>Michael Jackson</option>
<option>WestLife</option>
<option>Others</option>
</select></div>
<div style="position: absolute; width: 200px; height: 20px; z-index: 6; left: 212px; top: 147px" id="layer7">
<input name="name" type="text" style="width: 200px"></div>
<div style="position: absolute; width: 263px; height: 25px; z-index: 5; left: 213px; top: 94px" id="layer6">
<input name="File1" id="file" type="file" style="width: 232px; height: 25px"></div>
<div style="position: absolute; width: 116px; height: 27px; z-index: 4; left: 49px; top: 196px" id="layer5" class="style2">
Album</div>
<div style="position: absolute; width: 151px; height: 31px; z-index: 1; left: 20px; top: 24px" id="layer2" class="style1">
Upload</div>
<div style="position: absolute; width: 45px; height: 21px; z-index: 2; left: 51px; top: 94px" id="layer3" class="style2">
<label id="Label1">Song </label></div>
<div style="position: absolute; width: 97px; height: 31px; z-index: 3; left: 50px; top: 142px" id="layer4" class="style2">
Song Name</div>
<div style="position: absolute; width: 101px; height: 24px; z-index: 8; left: 186px; top: 281px" id="layer9">
<input name="upload" type="submit" value="Upload" style="width: 95px"></div>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.