Home Database Mysql Tutorial 我认为JSP有问题(下)_MySQL

我认为JSP有问题(下)_MySQL

Jun 01, 2016 pm 02:08 PM
jsp information Error Bag Can compile question page

  (作者:小龙亭主Blueski编译 2000年12月22日 14:22)

  (续上篇)

  问题 #3: 简单工作仍然很累人

  即使是很简单的工作,例如包含 header和 footer,在JSP中仍然很困难。假设有一个"header"和一个"footer"模板要包含到所有页面,而每一个模板要在content中包含当前的页标题。

  在JSP中最佳办法是:

  

  

  ...你的页面内容...

  

  页面设计者要记住不能遗漏第一行的分号并要将title定义为一个字符串。此外,/header.jsp和/footer.jsp必须在根目录下并且必须是可存取的完整文件。

  在WebMacro中包含headers和footers做起来比较简单:

  #set $title = "The Page Title"

  #parse "header.wm"

  Your content here

  #parse "footer.wm"

  这里对设计者来说没有要牢记的分号或对title的定义,.wm文件可以放在可自定义的搜索路径下。

  问题 #4: 很粗燥的循环

  在JSP中循环很困难。这里是用JSP重复打印出每一个ISP对象名字。

  
  Enumeration e = list.elements();

  while (e.hasMoreElements()) {

  out.print("The next name is ");

  out.println(((ISP)e.nextElement()).getName());

  out.print("
");

  }

  %>

  也许什么时候会有用户自定义标记来做这些循环。对"if"也是如此。JSP页可能看上去成了很古怪的java代码。而同时,webmacro循环很漂亮:

  #foreach $isp in $isps {

  The next name is $isp.Name


  }

  如果必要的话,#foreach指令可被自定义的 #foreach-backwards指令很容易地取代。

  用jsp的话很可能变这样:(这里是一个可能的 标记)

  

  The next name is


  


  设计者当然地会选择前者。

  问题 #5: 无用的出错信息

  JSP常有一些令人惊讶的出错信息。这是因为页面首先被转换成为一个servlet然后才进行编译。好的JSP 工具可以相对增加找到出错位置的可能性,但即使是最好的工具也无法使所有出错信息都能容易地被读懂。由于转化的过程,一些错误对工具来说可能根本不可能被识别。

  例如,假设JSP页面需要建立一个对所有页通用的标题。以下代码并没有错:

  

  但Tomcat会提供以下出错信息:

  work/%3A8080%2F/JC_0002ejspJC_jsp_1.java:70: Statement expected.

  static int count = 0;

  ^

  此信息认为以上脚本被放入 _jspService()方法而静态变量不允许放入方法中。该语法应该是 。页面设计者很难读懂这些出错信息。即使最好的平台在这方面也做得很不够。即使所有 Java代码都从页中移出也无法解决问题。另外,以下表达式有什么错?

  

  tomcat给出:

  work/8080/_0002ftest_0002ejsptest_jsp_0.java:56: Class count not found in

  type declaration.

  count

  ^

  work/8080/_0002ftest_0002ejsptest_jsp_0.java:59: Invalid declaration.

  out.write("\r\n");

  ^

  换句话说,其实只不过是遗失了一个标记而已。应该是 。

  由于template engine可以在template文件中直接产生而没有任何戏剧性的向代码转化,所以可以非常容易地给出适当的出错报告。依次类推,当c语言的命令被打入Unix shell的命令行,你并不希望shell会生成一个C程序来运行这个命令,而只是需要shell简单地解释命令并加以执行,如有错误也直接给出。

  问题 #6: 需要一个编译器

  JSP需要一个置放在webserver中的编译器。由于Sun拒绝放弃包含了他们的javac编译器的tools.jar库, 这其中就变得有问题了。Web服务器可以包含进一个第三方的编译器如ibm的jikes。但这样的编译器并不能在所有平台上顺利工作(用 C++写成的) 也不利于建立纯Java 的web服务器。JSP还有一个预编译选项可以起到一定作用,但并不完美。

  问题 #7: 空间的浪费

  JSP消耗了额外的内存和硬盘空间。对服务器上每30K的JSP文件,必须要有相应的大于30K的类文件产生。实际上使得硬盘空间加倍。考虑到JSP文件随时可以很容易地通过

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to copy a page in Word How to copy a page in Word Feb 20, 2024 am 10:09 AM

Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

Can I delete the downloads folder? Can I delete the downloads folder? Feb 19, 2024 pm 03:38 PM

Can downloads be deleted? In recent years, with the advent of the digital age, more and more digital products and services have appeared in our lives. What follows is that our demand for digital content is increasing day by day. In our daily life and work, we often need to download a variety of files, such as documents, pictures, audios, videos, etc. These downloaded files are usually saved in a folder called "downloads". However, over time we often find that,"

How to quickly refresh a web page? How to quickly refresh a web page? Feb 18, 2024 pm 01:14 PM

Page refresh is very common in our daily network use. When we visit a web page, we sometimes encounter some problems, such as the web page not loading or displaying abnormally, etc. At this time, we usually choose to refresh the page to solve the problem, so how to refresh the page quickly? Let’s discuss the shortcut keys for page refresh. The page refresh shortcut key is a method to quickly refresh the current web page through keyboard operations. In different operating systems and browsers, the shortcut keys for page refresh may be different. Below we use the common W

How to implement page jump in 3 seconds: PHP Programming Guide How to implement page jump in 3 seconds: PHP Programming Guide Mar 25, 2024 am 10:42 AM

Title: Implementation method of page jump in 3 seconds: PHP Programming Guide In web development, page jump is a common operation. Generally, we use meta tags in HTML or JavaScript methods to jump to pages. However, in some specific cases, we need to perform page jumps on the server side. This article will introduce how to use PHP programming to implement a function that automatically jumps to a specified page within 3 seconds, and will also give specific code examples. The basic principle of page jump using PHP. PHP is a kind of

How to deal with the problem that Laravel page cannot display CSS correctly How to deal with the problem that Laravel page cannot display CSS correctly Mar 10, 2024 am 11:33 AM

"Methods to handle Laravel pages that cannot display CSS correctly, need specific code examples" When using the Laravel framework to develop web applications, sometimes you will encounter the problem that the page cannot display CSS styles correctly, which may cause the page to render abnormal styles. Affect user experience. This article will introduce some methods to deal with the failure of Laravel pages to display CSS correctly, and provide specific code examples to help developers solve this common problem. 1. Check the file path. First check the path of the CSS file.

How to solve the problem that jQuery cannot obtain the form element value How to solve the problem that jQuery cannot obtain the form element value Feb 19, 2024 pm 02:01 PM

To solve the problem that jQuery.val() cannot be used, specific code examples are required. For front-end developers, using jQuery is one of the common operations. Among them, using the .val() method to get or set the value of a form element is a very common operation. However, in some specific cases, the problem of not being able to use the .val() method may arise. This article will introduce some common situations and solutions, and provide specific code examples. Problem Description When using jQuery to develop front-end pages, sometimes you will encounter

How to implement jsp paging function How to implement jsp paging function Mar 04, 2024 pm 04:40 PM

Implementation steps: 1. Introduce the JSTL tag library into the JSP page; 2. Obtain data from the database; 3. Paging the data; 4. Display the paging navigation bar in the page; 5. Display the number according to the current page number and each page. , just get the corresponding data from the paging data and display it on the page.

Introduction to how to delete a page of content in Word Introduction to how to delete a page of content in Word Mar 26, 2024 am 10:06 AM

Title: Introduction to how to delete a page of content in Word When editing a document using Microsoft Word, you may sometimes encounter a situation where you need to delete the content of a certain page. You may want to delete a blank page or unnecessary content on a certain page in the document. In response to this situation, we can take some methods to quickly and effectively delete a page of content. Next, some methods to delete a page of content in Microsoft Word will be introduced. Method 1: Delete a page of content First, open the Word document that needs to be edited. Certainly

See all articles