| Mark Damon Hughes | NetRexx Servlets |
|
|
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)
Last modified: 2006Jan13
|
Links:
Site Pages:
Blog ArchiveBlog Topics:
|