Score:0

Q.How to Retrieve File/Image from Database And Display in JSP web page using Hibernate , MySQL Database?

I need a code that can help me to retrieve my image/file from Mysql database and also display it on the webpage(.jsp) by using HIbernate and Servlet JSP. Q.How to Retrieve File/Image from Database And Display in JSP web page using Hibernate , MySQL Database?, Here's My Code...

`/**Employee and Login Registration*/

private void saveEmp(HttpServletRequest request, 
HttpServletResponse response) throws ServletException, IOException {        
Employee emp = new Employee();  
Part part = request.getPart("image");
InputStream is = null;

if(part != null) {
    is = part.getInputStream();
    byte[] data = new byte[is.available()];
    is.read();
    emp.setImage(data);     
            
boolean status = MainServices.saveEmp(emp);
        if(status)
        {
            MainServices.saveLoginData(login);
            request.setAttribute("msg", "Form Submitted Successfully...");
            request.getRequestDispatcher("adminHome.jsp").include(request, response);
        }
        else
        {
            request.setAttribute("msg","Email or Mobile Number is already Registered with us....");
            request.getRequestDispatcher("empForm.jsp").include(request, response);
        }
    }
}
David avatar
cn flag
What does this have to do with the unstated version of Ubuntu you are using?
in flag
Two suggestions: (1) read Joe Celko's books about databases (and specifically what *not* to do with them) (2) ask this question on StackOverflow, where you have a higher chance of receiving an answer
Okay Thankyou Sir
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.