SUN's translation documentation for JSWDK

zhaozj2021-02-17  55

JavaServer Pages (TM) Web Development Kit [FAQ]

This document lists some questions about JavaServer (TM) Web Development Kit (JSWDK) that are often referred to. Independent documents can be found on the Component Technologies (Servlets and JSP) of Java.sun.com.

1. Environment variables need to be set using JSWDK

You need to set a valid ClassPath variable for JDK. (For UNIX, JDK 1.1.x OR 1.2. For Windows, JDK 1.2)

If you are using JDK 1.2, you still need to operate according to the following suggestions.

· Set the JDK path in the Java_Home variable

· Set the path to Tools.jar in the class_path variable

Other necessary .classes and .jar files are set in the run script or batch file of the startserver command of JSWDK.

2. Where is the.classes file that runs JSPS and Servlets?

These documents are here:

· Webserver.jar - servlet compiler. Class file

· Lib / jspengine.jar - JSP compiler. Class file

· Lib / servlet.jar - public APIS file for servlet

· LIB / XML.jar - Analysis of XML files .class file

3. Can I use other webservers to integrate these .CLASS?

The JSP compiler actually only uses the common part of the Java Servlet 2.1 API. In theory, it can run on a servlet compiler that supports the Servlet 2.1 API. But Sun did not test the test on a servlet compiler except JSWDK.

4. What should I put my JSP file and a javabean file?

If you just try to run JSP instead of building a separate web application. You can use the default "example" program. If you are a new web application, please refer to the problem of setting up new web applications in FAQ.

Use the default "example" program:

<1> put all JSP source programs under the / Examples / JSP folder or placed in subdirectory of the folder.

<2> Place all the Class files of all the beans under the / Examples / Web-INF / JSP / Beans folder. The runtime script of the startserver command of JSWDK will automatically add these .class to the ClassPath variable.

<3> If your JSWDK server has already started running, stop it first, then we will follow up.

<4> Access your JSP file, please follow the address below

Http: // Locahost: 8080 / Examples / JSP / [Your JSP file name .jsp]

5. What is a web application?

A web application is a collection of resources mapped to a UNIFORM Resource Identifier (URI). These resources can include JSP files, servlets, html files, and pictures, and more.

For example, all resources related to basketball can be integrated into a "baseball" directory. All network accesss for address "/ baseball" can be mapped to the Web application corresponding to the "Baseball" directory. How do I create a new web application?

<1> Create a folder for the web application. In the following example, we establish a "WebApp" folder. If appropriate, we can also set this folder to make it the same as the Examples folder, with the same subdirectory, JSP, Servlets, Web-INF, and IMAGES. One way to achieve this goal is to copy an Examples and then make the necessary modifications.

<2> Add a web application by modifying the JSWDK root of the webserver.xml file.

For example, create a basketball application, you can add the following to the appropriate location of the webserver.xml file.

Please read the webserver.xml file for more information on logging rules and settings.

Then see the following questions about setting servlets, JSP files, and beans.

7. How do I create a servlets in a web application?

Please follow the steps below to perform the appropriate operations in your WebApp's folder.

<1> Compile the servlet and decide which web application is to be added to it.

<2> Add a servlet's .class file to the WebApp / Web-INF / Servlets folder.

<3> By adding Servlet's information to a webapp / web_inf / servlets.properties file, the servlet can be accessed by users. For the correct addition of information, please refer to the examples / web-inf / mapings.properties file.

<4> You can also implement the same purpose by adding the mapping information of the servlet to the webapp / web-inf / mappings.properties file, refer to the examples / web-inf / mapings.properties file.

<5> Last recycling server

You can access your servlet through the following address, add the servlet's name servlet_name on the URI address of Web Application WebApp.

Http: // localhost: 8080 / WebApp / servlet / servlet-name

If you are setting your servlet through a map, please go to the following method. Here Extension represents the extension of the file name, and the MAP-PATH represents a reasonable mapping address.

Http: // localhost: 8080 / Webapp / foo.extension

or

Http: // localhost: 8080 / WebApp / Map-path

8. How do I add my own JSP and Javabean in a web application?

<1> Place the JSP source file into the directory under the web application folder. (Just as / webapp) in the above example

<2> Verify that the path information of the compiled JavaBean has been set in the classpath parameter. You can manually set the classpath parameter, or edit the run script of the startserver command.

<3> Edit WebApp / Web-INF / MAPPINGS.PROPERTIES file and webApp / web-inf / servlets.properties file so that JSP servlets that may be associated with JSP files can access JSP files through the mapped address. (You can refer to the .properties file in the / examples / web-inf / folder, your mapping settings should be similar.) <4> Last recycling server

You can access your own JSP files in a way that is similar to the examples below.

Http: // localhost: 8080 / Webapp / yourfile.jsp

9. How is the URI map on the server?

The web server compares the requested URI address and all preamble icons in the web application. If there is no match, automatically use the default settings to replace it.

10. How to pass the data from the servlet to JSP?

You can refer to the JSP example in the JSP example in JSP examples to pass data to JSP from servlet, or pass data from JSP to servlet.

11. Significance of different initial parameters

KeepGenerated:

Decide whether to retain the generated Java file. The value can be True or False. Set to True, will retain the generated file, set to false, will remove these files after compiling.

Scratchdir:

Set the folder that retains all generated code. This can be set to any folder under DOCBASE.

Largefile:

The value is true or false, if set to True, indicating that all static HTML files are stored under a separate folder.

SenderrtoClient:

The value is True or false, and if it is set to True, all compilation / parsing errors are sent to the user.

IECLASSID:

This parameter is used to activate the PLUG-IN IE, and the default setting is for IE4 and IE5. If this IE-oriented parameter will be further modified in the future, it may play a greater role.

12. 404 What is wrong?

Representing the server can't find the resources you requested. This may be due to the following two reasons:

· The URL address error you entered.

· The URL is not placed in the main directory of the current server. If you are running your personal web app, read the instructions and documents related to your personal program.

13. 505 What is wrong?

505 Errors represent a "web server error" when handling your request. To find more error messages, observe the status display information of the server running window.

These errors may occur in compiling JSP source files to servlet. JSP files or syntax errors in the generated Java file is a typical reason for errors. Please display your program based on the status of the server running the window.

The time requested is another reason that may cause problems. Similarly, please debug the program based on the status of the server running the window.

转载请注明原文地址:https://www.9cbs.com/read-29810.html

New Post(0)