Download:
EJW 2.2 (new)
Examples
Documentation (pdf)
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:
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!
· An extremely easy web development framework
· Model-View-Controller architecture
· Incredibly easy server side AJAX support
· Full support for REST web services
· Simple configuration free web applications
· Easy-to-use URL to object mapping
· Extremely small learning curve (learn in minutes)
· All the functionality offered by other frameworks and more
· No proprietary tag libraries and no need for any
· Use JSP/JSTL, Velocity, or whatever you like
· Use regular HTML and Forms
· Optionally use any BSF compatible scripting language
· Extensive validation support for your data
· Easily handle forwarding, redirects, and non-secure connections
· Easily handle SSL(https)
· Role level security
· Container- and application-based authentication
· Built-in URL rewriting for handling cookie-limited browsers
· Multipart forms and file uploads
· Email with attachments and HTML
· Backend direct payment processing
· Support for regular expression matching
· Secure file downloading and uploading
· and more
All support requests, bug reports, code access, etc. can be found at SourceForge.net. Please be pro-active and report any issues and feature requests. Thank you!
If you would like to contribute code and/or fixes, please send a support request (via SourceForge.net) requesting commit access to our repository.
EJW can be found at https://sourceforge.net/projects/ejwebsites
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>
The following demonstrates the optional form features of EJW. EJW handles forms easily and without a bunch of tags. With EJW Interfacing between JSP and HTML forms is trivial.
Simply register an object for automatic form/object mapping:
serverInterface.addFormObject("objectName", object);
When a form is submitted, EJW automatically fills the object with data by matching form fields to object properties via property naming (ex. customerName). The object can be retrieved at anytime with getServerInterface().getFormObject():
Customer customer = getServerInterface().getFormObject("customer");
Simply use plain HTML and and your favorite template markup with ${form.anyObjectProperty}, and EJW will automatically handle populating the form/object:
<p>Customer Name
<input type="text" name="customerName" value="${form.customerName}" /></p>
With all the third party tag libraries (only JSTL is really needed), and with all the Javascript frameworks like jQuery and Dojo, there just is isn't a need for the tags that other frameworks force us to use. With EJW you simply use JSP/Velocity/etc, plain old HTML forms/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:
<input type="file" name="filename" />
This example sends an email with an image attachment that is also embedded in an HTML document
EmailSender es = new EmailSender("localhost");
es.setDebug(true);
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 is a EJW example of sending a backend payment to PayPal.
String username = "test_api1.host.com",
password = "VBAACCMQ5CN3V96D",
signature = "AXuvVdpyAeZUtSJ1yWJuCV6a8i33AdI-s9Lloti4HOkrytGZR7PeCH1q",
environment = "sandbox",
ipAddress = "1.1.1.1";
DirectPayment pp = new DirectPayment(username, password, signature, environment);
CreditCardInformation cci = new CreditCardInformation("0000000000000000",
"Visa", "000", "11", "2007");
CardOwnerInformation coi = new CardOwnerInformation("David", "B",
"123 No Street Drive", null, "Glendale", "AZ", "43844", "US");
pp.directPayment(ipAddress, 123.99, cci, coi);
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>