Create a login and registration system in Apache Geronimo, part 2nd: Building a registration system with JSP

Source: Internet
Author: User

Brief introduction

In the 1th part, a fictitious web Apps company created a Web site for customers that allows different levels of user authentication. Infrastructure development is done by creating database tables and security deployment plans for the application. In Geronimo's built-in Derby database, user tables and grouped tables are created through the Geronimo console. It then implements security by connecting to the sqlloginmodule of the Geronimo built-in Derby database, and matches the user name, password, and group with the information provided by the user at logon, allowing users in the table to access the forum.

In this article, the simple login system created in part 1th is expanded to include a user registration system that uses JSP. This allows new visitors to the customer's Web site to register and access the forum. First, you will learn about JSP and how they are implemented and their relationship to Geronimo. A Java servlet is then created to display forms that allow users to register by providing a user name, password, and e-mail address. The information is then submitted to the same servlet, which connects to the database and inserts a new record that contains information about the new user, allowing the user to log in.

Set up

Please refer to the beginning section in part 1th of this series for this part. Also, see the README.txt file in the compressed source file in the download section to get the modified directory structure.

In addition to the prerequisites listed in part 1th and the Java 2 SDK Standard Edition (J2SDK), you will also need to have EE 1.4 and JSP 2.0. JSP 2.0 is packaged with Java EE 1.4 and can be downloaded free of charge on the Sun Microsystems Web site.

Now it's time to start. Let's start with the introduction JSP.

Java Server Page

JSP is a form of Java technology for scripting languages. You can embed the Java language inside a Web page or create a Java class to act as a servlet. Like other scripting languages, JSP allows dynamic content to be generated based on content submitted to a Web page. However, the JSP and Servlet are written in the Java language, so they have the power of Cross-platform, Cross-platform portability using the Java language.

To fully understand the power of Geronimo, it is important to understand both JSP and servlet when building an application for Geronimo. You will now learn how to write simple. jsp files by writing the first script in JSP. Later in this article, you will learn how to write a servlet. The servlet is similar to the script written in JSP, but it is more secure because it is precompiled.

Scripting with JSP

The first JSP script will display the date and is written entirely in the Java language. Please create the jspscript.jsp file and define it as shown in Listing 1.

Listing 1. Scripting with JSP

<%
System.out.println("The script has started");
java.util.Date d = new java.util.Date();

out.println(" out.println("This is my first script written in JSP!<br>");
out.println("The historic time of this event is: ");
out.println(String.valueOf(d) + "<br>");
%>
Text displayed outside of the JSP script.<br>
<%
out.println("You can mix and match how you display text.");
out.println("</body> %>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.