Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Database Picture Storage and dynamic display based on WEB by JSP

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how JSP achieves WEB-based database picture storage and dynamic display. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Database applications, especially those based on WEB, often involve the storage and display of picture information.

Usually, the method we use is to store the picture to be displayed in a specific directory, save the name of the corresponding picture in the database, establish the corresponding data source in JSP, and use the database access technology to process the picture information. However, if we want to display pictures dynamically, the above methods will not meet the needs. We have to store the pictures in the database and then programmatically display the pictures we need dynamically. In practice, the programming mode of JSP can be used to realize the database storage and display of pictures.

Set up a background database

If exists (select * from dbo.sysobjects

Where id = object_id (N' [dbo]. [P]') and OBJECTPROPERTY (id, NumberIsUserTable`) = 1)

Drop table [dbo]. [p]

GO

CREATE TABLE [dbo]. [p] (

[picid] [int] IDENTITY (1,1) NOT NULL

[picname] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL

[pic] [image] NULL

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

Store binary pictures in the database

After starting Dreamweaver MX, create a new JSP file. The code is as follows.

My JSP 'InputImage.jsp' starting page title picture

Save this file as an InputImage.jsp file, where the testimage.jsp file is used to store the image data in the database. The specific code is as follows:

My JSP 'testimage.jsp' starting page

Dynamically display pictures on a web page

Next we are going to program to extract the picture from the database, the code is as follows.

My JSP 'testimageout.jsp' starting page

Save this file as a testimageout.jsp file. The next step is to use the HTML tag:

My JSP 'lookpic.jsp' starting page "width=" 100 "height=" 100 "> Thank you for your reading! On "JSP how to achieve WEB-based database picture storage and dynamic display" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report