Kisat
Posts: 4
|
Posted: 07/07/2008, 12:09 AM |
|
I can
File file = new file ("d:/new.jpg ")
and insert into oracle db
but now I want to select jpg than insert into my oracle db
<input type="file" name="uploadfile"> - like that
but I can't get location and get file. how I do pls help
|
|
|
sarrivillaga
Posts: 10
|
Posted: 07/07/2008, 10:54 AM |
|
You should implement a different servlet, and use it to read the file from the database and send it through the http response.
In your pages you shoud call your image like that:
<input type="file" name="uploadfile" src="getImage?imageid">
|
|
|
Kisat
Posts: 4
|
Posted: 07/07/2008, 7:50 PM |
|
My Jsp page:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/taglibs.jsp" %>
<stripes:layout-render name="/themes.jsp" pageTitle="Content">
<stripes:layout-component name="t.jsp">
<stripes:form action="/upload.action">
<br>
<fieldset>
<stripes:label for="">Pic name</stripes:label>
<br>
<input type="file" name = "pic">
<stripes:submit name="insert" value="add" />
</fieldset>
</stripes:form>
</stripes:layout-component>
</stripes:layout-render>
java page :__________________________________
@UrlBinding("/upload.action")
public class UploadBean extends CrimeActionBean {
private File pic;
........
public Resolution insert() {
BaseDAO myConn = new BaseDAO();
Connection conn = null;
conn = myConn.getConnection();
PreparedStatement ps = null;
try {
File file = new File(getPic().getPath()); - this is my my problem. I can't get file and file location. If I can get file than I will be insert into my Db. How do i decide this problem.
System.out.println(" location " + getPic().getPath());
FileInputStream fis = new FileInputStream(file);
ps = conn.prepareStatement("insert into pics(byrtgelId, pic) values (?,?)");
ps.setInt(1, 121212);
ps.setBinaryStream(2, fis, (int) file.length());
ps.executeUpdate();
ps.close();
fis.close();
} catch (Exception e) {
System.out.println("file upload exception: " + e.getMessage());
}
return new RedirectResolution("/upload.action");
}
.......
}
|
|
|
matheus
Posts: 386
|
Posted: 07/14/2008, 5:27 AM |
|
Where is Codecharge relationship?
_________________
Matheus Trevizan
Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br |
|
|
|