EJW can handle anything you need to do!
EJW is a powerful and easy to use model-view-controller web development framework for Java. EJW's main features include:
EJW is a Java servlet-based model-view-controller web development framework that is designed for extreme ease-of-use. In fact, we would dare to say EJW is the easiest framework available, and yet it still has all the abilities and functionality of any other framework, Java and non Java. Best of all, it can actually be learned in a matter of minutes; there is no huge learning curve.
EJW is this easy (no annotations or configuration):
public class HelloWorld extends RequestHandler
{
public String hello()
{
getServerInterface().addViewObject("helloWorld", "Hello World");
return "/WEB-INF/helloWorld.jsp";
}
}
Calling the above is this simple:
http://host/context/helloWorld/hello
Just use plain HTML and your favorite template markup (JSP, Velocity, etc.):
<div align="center">
<h3>Hello, This Is A Simple "Hello World" Example.</h3>
<h2>${helloWorld}</h2>
</div>
The following servlet configuration is all that is needed (outside our control, it's a Java servlet thing):
<servlet>
<servlet-name>ejwRequestServlet</servlet-name>
<servlet-class>ejw.RequestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ejwRequestServlet</servlet-name>
<url-pattern>/helloWorld/hello</url-pattern>
</servlet-mapping>
That's it! No other XML, annotation, or configuration is needed!
EJW can handle anything you need to do!
See below for documentation and support options
Please use the support form to initiate any support requests you may have and/or to notify us of any extra needs regarding your purchase. Thank you.
Note: If you don't receive a response within one business day, it's likely that your email address was incorrect.
Please use the support form to initiate any support requests you may have and/or to notify us of any extra needs regarding your purchase. Thank you.
public class HelloWorld extends RequestHandler
{
public String hello()
{
getServerInterface().addViewObject("helloWorld", "Hello World");
return "/WEB-INF/helloWorld.jsp";
}
}
<div align="center">
<h3>Hello, This Is A Simple "Hello World" Example.</h3>
<h2>${helloWorld}</h2>
</div>
http://host/context/helloWorld/hello
<servlet>
<servlet-name>ejwRequestServlet</servlet-name>
<servlet-class>ejw.RequestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ejwRequestServlet</servlet-name>
<url-pattern>/helloWorld/hello</url-pattern>
</servlet-mapping>
EJW provides simple options for both container managed authentication and for programmatic authentication. It's also trivial to implement your own solution or to use a third party solution. You can also use the new security options provided with the Servlet 3.x spec (Tomcat 7.x).
With EJW and EJP, programmatic web site security / authentication is as simple as:
public String login()
{
User user = getServerInterface().fillObject(new User());
user.password = Password.getEncryptedPassword((user.password));
if (AppUtils.getDatabaseManager(getServerInterface()).loadObject(user) != null)
getServerInterface().setRemoteUserInformation(user.username, user.getRoleMap());
else
getServerInterface().setApplicationMessage("Username/password not found");
return "/WEB-INF/view.jsp";
}
public String logout()
{
getServerInterface().invalidateRemoteUser();
return "/WEB-INF/view.jsp";
}
Your view is as simple as:
<c:if test="${!empty ejwRemoteUser}">
<p>You're logged in
</c:if>
<c:if test="${ejwRemoteUserInformation.roleMap.admin}">
<p>You're an administrator
</c:if>
See SimpleLogin.war to see this example in action.
With both container managed authentication and programmatic authentication, the following methods from ServerInterface (getServerInterface()) can be used:
and then you can use the following implicit view variables:
in your (JSP/Velocity/etc.) to control access to what your users can see and interact with.
EJW handles forms easily and without a bunch of tags (you can optionally use EJW's simple form tags). With EJW, interfacing between JSP and HTML forms is trivial and is handled with two simple methods:
fillObject();
addViewObject();
fillObject() fills any object(s) with request data (form submission data). addViewObject() makes data available to the view (JSP/Velocity/etc.). Then, simply use plain HTML/Forms, and your favorite template markup. With most development, all you will need is JSP expression language (EL) and Java standard tag library (JSTL), nothing more.
For example:
<form action="$(urlToFormHandler)">
<label>Customer Name</label>
<ejw:text id="customerName" />
<input type="submit" />
</form>
Then simply load the form into one or more of your objects with:
fillObject(customer);
With JSP EL, JSTL, and EJW Form tags, there just isn't a need for the extensive tag libraries that other frameworks force us to use. With EJW you simply use JSP/Velocity/etc, plain old HTML forms/tags, optionally use EJW's simple form tags, and your favorite javascript framework (or not).
The following is all that is needed to handle file uploads with EJW:
MultipartFormData mfd = getServerInterface().getMultipartFormData("filename");
mfd.getStoredLocation().renameTo(new File(newPath));
Simply Use typical HTML file upload form:
<form action="$(urlToFormHandler)" enctype="multipart/form-data">
<input type="file" name="filename" />
<input type="submit" />
</form>
This example sends an email with an image attachment that is also embedded in an HTML document
EmailSender es = new EmailSender("localhost");
es.addSendTo("user@somehost.net","User");
es.addReplyTo("d@localhost.com", "David");
es.setSentFrom("d@localhost.com", "David");
es.setSubject("This is an example");
String html = "<html><body><h1>This is an example message</h1>"
+ "<b>This is an example image <img src='cid:image'> message</b>"
+ "</body></html>";
es.addHtml(html);
es.addAttachment("image","images/logo_2_200x70.jpg","This is an example",false);
es.addHtml("<html><body><h1>This is an example message</h1></body></html>");
es.sendEmail();
The following demonstrates using the same URI mapping features of EJW to map URIs to scripts. Any BSF (Apache Bean Scripting Framework) supported scripting language can be used. And the scripts can be added dynamically anytime. With script caching turned off the scripts can even be modified at anytime.
print ("hello world"); // prints to the standard output log
serverInterface.addViewObject("helloWorldMessage",
"Hello, this is a scripting example");
return "/WEB-INF/helloWorld.jsp";
print ("hello again world"); // prints to the standard output log
serverInterface.addViewObject("helloWorldMessage",
"Hello again, this is another scripting example");
return "/WEB-INF/helloWorld.jsp";
<div align="center">
<h3>Hello, This Is A Simple "Hello World" Scripting Example.</h3>
<h2>${helloWorldMessage}</h2>
</div>
<!--
Can execute any script in the scriptingDirectory. The script
filename is obtained from the servlet's extra path information.
See HttpServletRequest.getPathInfo()
-->
<request id="scripts" handlerClass="ejw.request.Scripting">
<parameter name="scriptFileNameExtension" value="bsh" />
<parameter name="scriptingDirectory" value="/WEB-INF/scripts" />
<!-- You can also pass arguments to your scripts -->
<parameter name="myScriptArg" value="myScriptArgValue" />
</request>
<!-- Only allows the following script -->
<request id="script" handlerClass="ejw.request.Scripting">
<parameter name="scriptFileName" value="/WEB-INF/scripts/hello.bsh" />
</request>
http://host/context/script
http://host/context/scripts/hello
http://host/context/scripts/helloAgain
<servlet>
<servlet-name>ejwRequestServlet</servlet-name>
<servlet-class>ejw.RequestServlet</servlet-class>
<init-param>
<param-name>configFile</param-name>
<param-value>/WEB-INF/webapp.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>ejwRequestServlet</servlet-name>
<url-pattern>/script</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ejwRequestServlet</servlet-name>
<url-pattern>/scripts/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
EJP/EJW provide functionality via the License class that handles permanent, and time keyed licensing. The keys generated by the License class look similar to:
P083210FE2DF9917274194876335C2D1CIISS2H96
for a permanent key. And:
T2D13C91E0138B070468F0FEBA0889A9783DB5DCD0D56F5ECDZ0M3OIF
for a temporary (time in weeks) key. There is also a CRC32 generated number associated with a given pass phrase:
1476833034
So, there is a pass phrase that is converted to a CRC32 checksum, along with a randomly generated password (the last 8 characters of the key), and optionally including expiration information. Any or all parts can be sent via a licensing server (your implementation).
This section goes in your central (main) class:
private static License license = new License(1000, "Without a key this software will run for 1000 iterations");
static // optional
{
try
{
Class.forName("LicenseKey");
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
public static void setLicenseKey(String licenseKey) throws LicenseException
{
license = new License(licenseKey, 1476833034L);
}
public static License getLicense() { return license; }
The following is used in one or more (many) places to check if the license is valid.
getLicense().isLicenseValid()
or
YourClass.getLicense().isLicenseValid()
The following (temporary or permanent key) can be placed in a jar file and given to your users:
public class LicenseKey // optional
{
static int test = 0; // needed to initialize the static section
static
{
try
{
YourClass.setLicenseKey("T2D13C91E0138B070468F0FEBA0889A9783DB5DCD0D56F5ECDZ0M3OIF");
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
}
You can also simply provide the license key:
T2D13C91E0138B070468F0FEBA0889A9783DB5DCD0D56F5ECDZ0M3OIF
and have your users set the key with:
YourClass.setLicenseKey("T2D13C91E0138B070468F0FEBA0889A9783DB5DCD0D56F5ECDZ0M3OIF");
in their code.