Java Server Pages technology - Design and development of web-applications

Java Server Pages Technology

JSP technology was Sun's response to the popularity of Microsoft ASP technology. An example of a simple JSP-page (template) is shown in Fig. 3.8.

The first line of this example shows the page directive & lt;% @ rade ... & gt; (it's interesting to note its similarity to the ASP.Nct web form directive), which specifies the import of classes from the package. The next line executes a variable declaration. The Java code is allocated (as well as in PHP and ASP) by special character sequences & lt;% ...% & gt;.

Example of a simple JSP page

Fig. 3.8. Example of a simple JSP page

Like PHP, JSP pages are implemented using a preprocessor that translates (translates) them into the source code of the servlet. HTML markup that stands outside of the selected blocks is translated into the Java print statements (as shown in Figure 3.9).

JSP technology has evolved, and over time, new features such as the JSP tag library (JSP taglib) have been added to it. Tag library taglib - is a set of special ( server) JSP tags that are not sent in the HTTP response to the browser, but are used when processing the JSP page in the servlet container on the side of the web server.

Actually, each special tag is some functionality, for implementation of which otherwise it would be necessary to include some built-in block containing Java-code. For example, the two most commonly used tags are: & lt; jsp: useBean & gt; and & lt; jsp: getProperty & gt ;. The prefix "jsp: says that this is not an HTML tag, but a special (server-side) tag that will be used on the server side. The & lt; jsp: useBean & gt; allows developers to embed JavaBean objects in the JSP page (created and filled with the application during the user's session). You can access and change their values ​​using the & lt; jsp: getProperty & gt; and & lt; jsp: setProperty & gt;.

The translation result of the JSP page shown in Figure 3.8 in the servlet code

Fig. 3.9. The translation result of the JSP page, shown in Fig. 3.8 in the servlet code

During the translation of the JSP page, which takes place before the compilation and execution of the created servlet, such special tags are converted to Java-code. For example, there is the following fragment of a JSP page:

& lt;/p & gt;

This fragment will be translated into the following Java code:

MyBean myBean = (MyBean) session.getAttributefmyBean '');

out.print ( & lt; p & gt; The value of the thing property is' +

myBean.getThing (). toString () + '. & lt;/p & gt; & quot ;;

Note the syntactic complexity associated with the substitution of variables in the JSP environment. To access the JavaBean property, a special tag should be included. An alternative way is to use the syntax & lt;% = object.variable% & gt;.

Also We Can Offer!

Other services that we offer

If you don’t see the necessary subject, paper type, or topic in our list of available services and examples, don’t worry! We have a number of other academic disciplines to suit the needs of anyone who visits this website looking for help.

How to ...

We made your life easier with putting together a big number of articles and guidelines on how to plan and write different types of assignments (Essay, Research Paper, Dissertation etc)