Sunday 15 June 2014

java - how output display in jsp using jstl, servlet -


sorry my english i started studying technology and java did not make me clear from some points. How do I get Meven connects I image pattern I am using DAO data base would, but I just output the image of JSP and do not know how to use Jestiel and servlet tell me that picture in JSP or

< P> Object class Posted :

  Public class mail {// code @Lob @Column (name = "IMAGE", drain = false) Private byte [] ; } // Code Public Zero Setizes (Byte [] image) {this.image = image; } Public Byte [] getImge () {Return Image; }}  

Postdao interface:

  public interface Postdao {// code public collection getAllPost (); }  

PostDaoImpl

  public class implements Postdao {// code public collection getAllPost (Postdaoaimpiel) {// this Method return list item session session = null; List Post = New Arrestist & lt; Posts & gt; (); Try {session = HibernateUtil.getSessionFactory (). OpenSession (); Post = session Creation classification (post.class) .list (); } Hold (exception e) {outputError ("getAllPost", e); } Finally {closed session (session); } Return post; } // code}  

The servlet Indekssiyr

  safety Whoid doGet (Actiteepisrvet request, Actiteepisrvet response feedback) Srvislet Akspshn , IOException throws {PrintWriter out = response.getWriter (); Response.setContentType ("text / html"); // session session session session = HibernateUtil.getSessionFactory (). GetCurrentSession (); Session.beginTransaction (); Try {// archive archive all the object collection allpost = Factory.getInstance (). GetPostDAO () GetAllPost (); Request.setAttribute ("allpost", allpost); Request (request / response); } Hold (exception e) {System.out.println (e); } Finally {if (session! = Open tap & session) ()) session.close (); }}  

and index.jsp using JSTL

  & lt; C: forEach var = "allpost" item = "$ {} allpost" & gt; & Lt; Img src = "$ {allpost.image}" alt = "..." & gt; & Lt; / C: foreach & gt;  

Error:

javax.el.PropertyNotFoundException: Property 'image' of not readable on app.web.landing.poy. Posted on Javax.el. javax.el.BeanELResolver $ BeanProperty.access $ 000 on javax.el.BeanELResolver.getValue (BeanELResolver.java:245) .BeanELResolver $ BeanProperty.read (BeanELResolver.java:297) (BeanELResolver.java:85) on ... ".........

there is a mistake in your Post # getImge should be post # getImage . When you use the property of a class while using EL, then he will get the method of that property.

Then post your change

  public class posts {@Lob @Column is as follows (name = "image", tap = false ) Private Byte [] Image; // Code Public Zero Setizes (Byte [] image) {this.image = image; } Public Byte [] getImage () {Return Image; }}  

No comments:

Post a Comment