Mark Damon Hughes NetRexx Servlets [Parental Advisory: Explicit Lyrics] [about]

Index  |   What is NetRexx?  |   NetRexx Servlets  |  

One of NetRexx's greatest strengths is string manipulation, and of course the web is nothing but text.

Rather than accumulate HTML in the servlet, I prefer to set request scope attributes, then forward to a JSP template page which uses JSTL and EL (but no inline Java code!). This lets me keep all business logic in the servlet, and all display logic in the JSP template page.


/* Greeting.nrx */

package foo

import javax.servlet.
import javax.servlet.http.

class Greeting extends NrxServlet
    method doGet(request=HttpServletRequest, response=HttpServletResponse)
	name = param(request, "name")
	name = name.reverse()
	request.setAttribute("name", name.toString())
	forward(request, response, "/greeting.jsp")

<!-- greeting.jsp -->
<p>Hello, ${requestScope.name}!</p>

/* NrxServlet.nrx */

package foo

import javax.servlet.
import javax.servlet.http.

class NrxServlet extends HttpServlet
    method param(request=HttpServletRequest, key)
	value = request.getParameter(key)
	if value == null then signal ServletException("Missing parameter" key)
	return Rexx value

    method forward(request=HttpServletRequest, response=HttpServletResponse, path)
            signals ServletException, IOException
	rd = getServletContext().getRequestDispatcher(path)
	rd.forward(request, response)
* nrxservlet.zip
A zip file containing the servlet, web.xml, and the NetRexx runtime library (NetRexxR.jar). Drop it in your Tomcat webapps dir, or copy it to get a framework for building new NetRexx webapps.

Last modified: 2006Jan13
Created

Links:


+-Mark Damon Hughes: Software Gallery
+-Mark Damon Hughes: Software Gallery Blog
+-@mdhughes on Twitter
+-
iPhone Games:

+-Castles: Strategy wargame for the iPhone.
+-DungeonDice: Tabletop RPG dice roller for the iPhone.
+-Nexus Worlds: Multiplayer Online Adventure Game for the iPhone.
+-
Computer Games:

+-Perilar: Adventures in the Dragon Kingdoms.
+-Hephaestus: Computer RPG construction kit.
+-GameScroll: Simple interactive fiction authoring.
+-Aiee!: "An Interactive Environment Engine" text adventure system.
+-Umbra: Post-apocalpytic computer RPG.
+-
Utilities:

+-JICB: Portable ICB client written in Java.
+-ThoughtPad: A tiny note-taking utility.

Site Pages:


+-Audio
+-Blank page
+-Camera
+-Cyberpunk
+-Game Design
+-Hacker
    +-Java
    +-NetRexx
    +-Python
+-Hello Kitty
+-Quotes
+-Religion
+-RPG
    +-The Bomb
    +-DUDE
    +-G.P.A.
    +-Phobos
    +-SIX WORD RPG!
    +-Weapons
    +-What's Wrong
  With AD&D?

+-Text
    +-H.Beam Piper
    +-Snow Crash
+-Universal Search
+-Video
+-Videogames
+-Virus Warning

Blog Archive
Blog Topics:


+-News
+-Cocoa
+-Mac
+-Media
+-Personal
+-Quotes
+-Religion
+-Roleplaying
+-Science
+-SecondLife
+-Society
+-Software
+-Toys
+-Web

Feedback  | Key: ] =local file, * =off-site link  | Copyright © 2003-2005 by Mark Damon Hughes | Subscribe with RSS 2.0
This site was created with Vim :wq