This application illustrates how to retrieve image and data from MySQL table using NetBeans IDE.
In this application we create a jsp page to display image. In this JSP page we are using <h:graphicImage> tag to access the servlet, here we are uses servlet but as u wish u can access a jsp page also. To create the project in the NetBeans IDE select File > click on "Create Project" then a New Project window will be appear, select Web from Categories section and select Web Application from Projects section. Click Next.

Put Project Name and click Next.

Choose JavaServer Faces and click Finish.

To create the jsp file right click on Web Pages select New and click JSP as below:

Here is the Source Code of data.jsp
<%@page contentType="text/html"%>
|
To create the package right click on Source Package and select New > Java Package..

The following window will appear then put package name and click Finish.

To create the java class right click on newly created package and select New > Java Class

Put the Class Name and click Finish.

Source Code of DisplayImage.java
package roseindia;
|
Create Bean class to set and get the table column as below the source code of TableBean.java
package roseindia;
|
Servlet Mapping in web.xml
| <servlet> <servlet-name>DisplayImage</servlet-name> <servlet-class>roseindia.DisplayImage</servlet-class> </servlet> <servlet-mapping> <servlet-name>DisplayImage</servlet-name> <url-pattern>/DisplayImage</url-pattern> </servlet-mapping> |
Source Code of faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
|
The Output shown on the Browser as below:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Retrieve Image in JSF From MySQL Table Using NetBeans IDE
Post your Comment