Security is defined as the condition of being protected against danger or loss. The security is very important in any web application as the web applications are mostly exposed to all the people in the world. The levels of security can be
- Transport Level security using HTTPS.
- Authentication and Authorization
- Role Based Access Control
- Container-managed Security
- Application-managed Security.
The web application can be configured to use any level of security as per the requirement and criticality of the site.
Application Managed Vs Container Managed Security
Container Managed | Application Managed |
|
|
The following is the Example to implement the Container Specific Security in Tomcat.
(1) tomcat-user.xml File
<?xml version =' 1.0 ' encoding =' utf-8 '?>
<tomcat-users>
<role rolename =" tomcat "/>
<role rolename =" role1 "/>
<role rolename =" admin "/>
<user username =" tomcat " password =" tomcat" roles =" tomcat "/>
<user username =" both " password =" tomcat" roles =" tomcat,role1 "/>
<user username =" role1 " password =" tomcat" roles =" role1 "/>
<user username =" visualbuilder " password =" test " roles =" admin "/>
</tomcat-users>
(2) Web.xml file
<?xml version =" 1.0 " encoding =" UTF-8 "?>
<web-app version =" 2.4 " xmlns =" http://java.sun.com/xml/ns/j2ee " xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance " xsi:schemaLocation =" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
<security-constraint>
<web-resource-collection>
<web-resource-name> application </web-resource-name>
<url-pattern> /security.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name> admin </role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method> BASIC </auth-method>
<realm-name> securityapp </realm-name>
</login-config>
<security-role>
<description> Testing the Application Security </description>
<role-name> admin </role-name>
</security-role>
</web-app>
Output:-
The following screen appears when you try to run the application. It will ask for username and password and once you enter "visualbuilder" as username and "test" as password then only it will display the pages of the application.
Jsp Discussion
- - How to rip a DVD fast?
- - I want good jsp tutorials
- - Two forms in one JSP
- - PASS VARIABLES BETWEEN 2
- - Table data





