Django concepts
Django's documentation lists these concepts:
- models
- view classes
- templates
- template tags
- url conf, routing of URLs
- forms
Java web development concepts
With Java EE and servlets we have these ideas:
- servlets
- Action (struts)
- JSP page
- FormBean
- DynamicFormBean
- web.xml
- struts-config.xml
Mapping Java to Django
Important: these concept mappings are only approximations. The Java concepts may allow more, or less, functionality.
JavaBeans are your models, where business logic happens.
The URLConf in Django is approximated by the web.xml and struts-config.xml files. The web.xml
file allows you to map urls to servlets and JSP pages among other things. The struts-config.xml
file maps URLs to Struts Action classes among other things. Here's how to write Action mappings.
Action classes and servlet classes are views. In Django terms, the struts Action class and servlets are close to a View class handling the most basic dispatch methods. The struts ActionForm classes are closer to a FormView, where request parameters are processed into a form and validated.
ActionForm beans are similar to the Django Form class. You can define these forms in the struts-config.xml
file, something you can't do in Django.
JSP pages are similar to templates and have access to template tags. The template language is known as the Expression Language, and the built-in template tags and filters are part of the JSTL (JavaServerPages Standard Tag Library. You can implement custom template tags by following this guide.
When using Struts, the Struts Tag Library can also be considered a set of built-in template tags.
The Struts Tiles component is far more similar to the Django template language, featuring components (a.k.a. "blocks") that can be extended and replaced.
Internationalization is handled by using a properties file. This is similar to using GNU gettext files with Django and creating new translation files for each language you want to support.
You can read this answer for information about session management which is equivalent to Django's Sessions middleware.