使用JSP连接数据库 [英] Connect database using JSP

查看:119
本文介绍了使用JSP连接数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JSP中使用jdbc驱动程序连接到数据库,我想了解什么是最好的连接数据库的方法?
jsp 中连接数据库是一个好方法?

I connected to database using jdbc driver in JSP and I want to learn what is the best way to connect database? Connect database in jsp is a good way? if not what is the best way ?

推荐答案

编程习惯

通常,避免在JSP页面中编写Java代码(声明,脚本和表达式),原因如下:

In general, avoid writing Java code (declarations, scriptlets and expressions) in your JSP pages, for the following reasons:


  • 在页面部署之前,不会检测JSP页面中Java代码的语法错误。

  • Syntax errors in Java code in a JSP page are not detected until the page is deployed. Syntax errors in tag libraries and servlets, on the other hand, are detected prior to deployment.

JSP页面中的Java代码更难调试。

Java code in JSP pages is harder to debug.

普遍接受的做法是不将复杂的业务逻辑与表示逻辑混合。 JSP页面主要用于演示逻辑。

It is generally accepted practice not to mix complex business logic with presentation logic. JSP pages are primarily intended for presentation logic.

包含Java代码,HTML和其他脚本指令的代码很难阅读。

Code containing Java code, HTML and other scripting instructions can be hard to read.

JSP 2.0规范正在削弱scriptlet,倾向于使用更简单的表达式语言。如果您的页面中未使用Java代码,那么将更容易将您的JSP页面演化为JSP 2.0样式编程。

The JSP 2.0 Specification is deemphasizing scriptlets in favor of a much simpler expression language. It will be easier to evolve your JSP pages to JSP 2.0-style programming if Java code is not used in your pages.

Oracle文档

这篇关于使用JSP连接数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆