Understanding JSP Files

A JSP PAGE is a text document that has two different kinds of text in it: JSP elements, which create dynamic content, and static data, which can be written in any text-based format (such HTML, SVG, WML, and XML).

The .jsp file extension is advised for a JSP page’s source file.

Two syntaxes—standard and XML—may be used to express the JSP elements in a JSP page, albeit only one syntax can be used in a single file.

Tools and APIs for XML documents can be used to alter a JSP page, which is an XML document in XML syntax.

The form on the web page shown in Figure 5-1 lets you choose a locale and shows the date according to that locale.

In the _tut-install_/javaeetutorial5/examples/web/date/ directory is the source code for this example.

Below is the JSP page, index.jsp, which is a standard combination of JSP elements and static HTML markup.

The following categories of JSP constructs are present in the example code’s bolded lines:

  • The content type that the page returns is determined by a page directive (<%@PAGE... %>).
  • Custom tag libraries are imported using tag library directives (<%@TAGLIB... %>).

Let’s investigate if JSP and HTML are the same.

HTML: Use HTML to print static data if you wish to print some information that won’t change in the future.

Apply:

  • Web pages are made with it.
  • HTML 5 Simple HTML Code is the most recent version. This is an illustration of a standard HTML page.

We will next learn how to open JSP files with Chrome.

When you hover over an area in IntelliJ when creating a web page, browser icons will show up in the upper right corner of the editor.

I used to be able to click on my IntelliJ-Chrome icon if the active file in the editor was a JSP.

This would open Chrome, and the JSP would show up as it would appear in the browser.

Now, Chrome only shows the JSP source code that is open in the editor when I click on my IntelliJ-Chrome icon.

I’ve discovered that instead of using localhost, the address bar in Chrome displays the location of the file on my hard drive when these JSPs are displayed.

Naturally, I’ve configured my Tomcat Run Configuration for the project, but I’m wondering if there’s something in IntelliJ that’s preventing the JSP from passing through my Tomcat setup.

I can change the path so that it points to http:localhost:8080, but doing so only opens the project welcome page in the OS default browser instead of the editor’s active page.

Let’s discuss how to launch a JSP file.

The Apache Software Foundation (ASF) created this open source web server and servlet container.

It offers a pure Java HTTP web server environment for the execution of Java code and implements the Java Servlet and JavaServer Pages (JSP) specifications.

  1. Set up Java.
  2. Set up Tomcat Apache.
  3. Go to Start, Programs, Apache Tomcat, and Monitor Tomcat right now.
  4. After completing the previous step, an icon will automatically appear on the taskbar.
  5. When you click on that icon, TOMCAT will start and the dialog box below will appear.