Skip to Content
Java EE 8 Development with Eclipse
book

Java EE 8 Development with Eclipse

by Ram Kulkarni
June 2018
Intermediate to advanced
596 pages
12h 39m
English
Packt Publishing
Content preview from Java EE 8 Development with Eclipse

Securing servlets using annotations

So far, we have seen declarative syntax for specifying security constraints; that is, by specifying <security-constraint> in web.xml. However, security constraints can also be specified using Java annotations, specifically for servlets. In this section, we will create AdminServlet and secure it with annotations. Follow the steps in the previous section to import the CourseManagementJDBC project from Chapter09, but rename it CourseManagementJDBC-SecureAnnotations, and import it into the workspace. Then, add only <login-config> in web.xml, but do not specify <security-constraint>:

  <login-config>    <auth-method>FORM</auth-method>    <form-login-config>      <form-login-page>/login.jsp</form-login-page> <form-error-page>/login-error.jsp</form-error-page> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java EE 8 Application Development

Java EE 8 Application Development

David R. Heffelfinger
Beginning EJB in Java EE 8: Building Applications with Enterprise JavaBeans

Beginning EJB in Java EE 8: Building Applications with Enterprise JavaBeans

Jonathan Wetherbee, Massimo Nardone, Chirag Rathod, Raghu Kodali

Publisher Resources

ISBN: 9781788833776Supplemental Content