Hello Everyone,
I am making this form in
jsp:-
<form action="editmovie.do">
Movie Name: <input type="text" name="moviename" size="40">
Movie Certification:
<select name="certification">
<option value="A">A</option>
<option value="U">U</option>
<option value="U/A" selected>U/A</option>
</select>
Movie Details:
<textarea rows="5" cols="40" name="details"></textarea>
<input type="submit" name="Submit">
</form>
I want to give an option to user to upload a movie image. I want to do this with same ActionForm(editmovie.do) in this jsp form.
Please help me with this and please tell me that can I use different data type other than blob in DB2.
What if I want to store only name or link of image in database?
Action Class
package booktickets.actions;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Connection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import Singleton.SingltonConntn;
import booktickets.forms.EditFormBean;
/**
* @version 1.0
* @author
*/
public class EditmovieAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ActionMessages errors = new ActionMessages();
ActionForward forward = new ActionForward(); // return value
try {
EditFormBean e=(EditFormBean) form;
String mname = e.getMoviename();
String mcer=e.getCertification();
String mdet=e.getDetails();
Connection con=SingltonConntn.getConn();
Statement st=con.createStatement();
st.executeUpdate("insert into movies (m_name,m_certification,m_details) values('"+mname+"','"+mcer+"','"+mdet+"')");
forward=mapping.findForward("check");
// do something here
} catch (Exception e) {
// Report the error using the appropriate name and ID.
errors.add("name", new ActionMessage("id"));
}
// If a message is required, save the specified key(s)
// into the request for use by the <
struts:errors> tag.
if (!errors.isEmpty()) {
saveErrors(request, errors);
// Forward control to the appropriate 'failure' URI (change name as desired)
// forward = mapping.findForward("failure");
} else {
// Forward control to the appropriate 'success' URI (change name as desired)
// forward = mapping.findForward("success");
}
// Finish with
return (forward);
}
}
please tell me the changes I have to do.