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

What are the test questions that JSP often meets?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly shows you "what are the test questions you often meet with JSP". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what are the questions you meet frequently in JSP?"

1: what is Jsp?

Java Server Page combines java and html to dynamically generate web pages on the server side

2: describe the running process of the Jsp page?

Step one:

Request to enter the Web container to translate the JSP page into Servlet code

Step 2:

Compile the Servlet code and load the compiled class files into the Web Container (JVM) environment

Step 3:

The Web container creates an instance of the Servlet class for the JSP page and executes the jspInit method

Step 4:

The Web container calls the _ jspService method of the Servlet instance for the JSP page; sends the result to the user

3: describe the functions, writing, and examples of the five types of script elements on the Jsp page

Note: instruction tags affect the translation phase of JSP pages: declaration tags declare tags allow JSP page developers to include class-level declarations: script tags allow JSP page developers to include arbitrary Java code in the _ jspService method: expression tags encapsulate Java runtime expressions Its value is sent to the HTTP response stream: Ten is

4: describe the types and writing of comments in the Jsp page

HTML comment

JSP page comments

Java comment

5: describe the function, writing, and examples of instruction tags on Jsp pages

Instruction tags affect the translation phase of JSP pages

6: describe the function, writing, and examples of the declaration tag of a Jsp page

Declaration tags allow JSP page developers to include class-level declarations

Written as follows:

Example:

7: describe the rules for translating Jsp pages into Servlet

Comment tags in jsp are translated into comments in the Servlet class

Instruction tags in jsp are translated into import statements in Servlet classes, etc.

Declaration tags in jsp are translated into attributes in the Servlet class

The script tag in jsp is transferred to the code in the service method in the Servlet class

Expression tags in jsp are translated into code in parentheses of write () or print () methods in the Serlvet class

8: describe the function, usage, and examples of the nine predefined variables on the Jsp page

Request the HttpServletRequest object associated with the request

Response HttpServletResponse objects related to the response sent back to the browser

Out JspWriter objects related to the output stream of the response

Session the HttpSession object associated with a given user's request session, which is meaningful only if the JSP page participates in a HTTP session

Applicationn ServletContext object for Web applications

Config ServletConfig objects related to the servlet of the JSP page

PageContext this object encapsulates an environment for JSP page requests

Page this variable is equivalent to the this variable in the Java programming language

Exception A Throwable object thrown by another JSP page. This variable is only available in the JSP error Page.

The function, writing, and example of the 9:page instruction, and describes the function and usage of its following attributes: import, session, buffer, errorPage, isErrorPage, ContentType, pageEncoding

Import: import defines a set of servlet class definitions that must be imported, and the values are a list of full class names or packages separated by commas.

Session: session defines whether the JSP page participates in a HTTP session. The value can be true (default) or false.

Buffer: buffer defines the buffer size used for the output stream (JspWriter object). The value can be none or Nkb, and the default is 8KB or greater.

ErrorPage: used to specify that another jsp page handles all exceptions thrown by that page

IsErrorPage: defines the JSP page as the target of the errorPage attribute of other JSP pages, with a value of true or false (the default).

ContentType: defines the MIME type of the output stream, which defaults to text/html.

PageEncoding: defines the character encoding of the output stream. The default is ISO-8859-1.

10: describe the functions of each part of MVC?

Model

Encapsulate application statu

Respond to status query

Expose the functionality of the application

Controller

Verify the data requested by HTTP

Map user data to model updates

Select the view to use for response

View

Generate HTML response

Request an update to the model

Provide HTML form for user requests

11: what is the Model 1 structure and the functions of each part of the structure

Using jsp in Model1 to deal with the view control part of web application

Jsp+javabean

12: what is JavaBean?

Users can use JavaBean to transfer functions, processing, values, database access, and any other available java code

The created objects are packaged, and other developers can use the internal JSP page, Servlet, and its

He JavaBean, applet program or application to use these objects.

13:JavaBean rules?

Define properties using the get and set methods

A non-parameter construction method

No public instance variable

14: what is the jsp standard action? Including those? What are the functions of each? How to use it?

XML-like tags are used in JSP pages to represent runtime actions

Jsp:userBean

Jsp:setProperty

Jsp:getProperty

Jsp:parameter

Jsp:include

Jsp:forward

15: use code to illustrate the use of the following standard actions: useBean, getProperty, setProperty

16: describe the four scope of Bean

Request

Session

Application

Page

17: describe the corresponding rules for the fields on the description page and the attributes in Bean

Id refers to the variable name of javabean

Class refers to the full path of the javabean class

Scope refers to the scope of application of javabean

Name refers to the variable name of the javabean used

Property refers to attributes in javabean

18: describe the processing of useBean actions

Declare variables using id

Try to find an object within the specified range

If you don't find it,

Create an instance of a class

Perform useBean tag body initialization object

If you find it

Converts an object to the type specified by the class

19: describe the functions of forward actions

When you use script code to process a request, you can use the jsp:forward action to produce a different view

Use the same request:

20: what is the Model 2 structure and the function of each part of the structure

Jsp+javabean+servlet

The Model 2 architecture uses MVC mode, JSP pages act as views, and Servlet acts as controllers

Servlet Controller:

Validate HTML form data

Invoke business services in the model

Store domain objects within the scope of a request (or session)

Select the next user's view

JSP page view:

Use the user interface (in HTML)

Access domain object

21: how do I get a distributor? What is the function of the dispenser?

Dispenser in the context object:

ServletContext context = getServletContext (); RequestDispatcher servlet = context.getNamedDispatcher ("MyServlet"); servlet.forward (request, response)

Dispatcher in the request object:

RequestDispatcher view = request.getRequestDispatcher ("tools/nails.jsp"); view.forward (request, response)

You can forward the request to another jsp page

When the request is issued from the client to an is request (1), and the a request b is request (2), it becomes two different requests, using RequestDispatcher to keep the original request (RequestDispatcher when the same request is maintained between different servlet)

RequestDispatcher rd = request.getRequestDispatcher ("string"); rd.forword (request); / / go to the next request to the next servlet

22: describe two ways to introduce additional pages into Jsp?

23: compare the characteristics of the above two methods

During recompilation, another page is completely embedded in this page, which can be said to be a page.

You can share variables here.

Add another page to this page during dynamic re-run, which can be said to be two pages, and variables cannot be shared.

24: what is a custom tag

The custom tag library is a Web component

These include:

A tag library descriptor file

All related tag handler classes

25: describe the steps for using custom tags and the detailed work of each step

1. Custom tags follow XML markup rules

Custom tags use XML rules

Tag name attributes and prefixes are case sensitive

Tag nesting rule

two。 You need to declare the tag library in the JSP page and in the deployment descriptor of the Web application:

Taglib

Use the taglib element in the deployment descriptor to declare that web applications use a tag library

Use the taglib directive in the jsp page to indicate which tag library to use and the prefixes used by the corresponding custom tags

Use custom empty tags

Use custom conditional tags

Use custom iteration tags

3. Custom empty tags can be used in JSP pages

GetPepParam () tag: inserts a named request flag into the output

4. Use custom tags in a JSP page to conditionally execute a portion of the HTML response

Heading tag: generate a hidden Html table to create a colored and formatted page header

5. Use custom tags in the JSP page to iterate through a portion of the HTML response:

IterateOverErrors tags: iterate over all anomalies in stutas

Taglib

1. Roast the class.

two。 Put the Taglib description file (* .tld) in the web-inf root directory

3. Configure in web.xml

4. Go back to the page and define the prefix used by Taglib

5. Use it directly. Be sure to end it.

The above is all the contents of the article "what are the test questions you often meet with JSP?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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