Pages

Sunday, December 17, 2006

A Simple EL Example


Problem: Using EL we need to render the form submitted in another html (when we submit the form we need to show the same form with filled in details)
Solution:
Using request scope
Consider that we have form.jsp which has the form to be saved(or whatever) and
preview.jsp is going to render the preview.


Code for form.jsp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>Input form</title>
</head>
<body>
<form action="preview.jsp">
<input type="text" name="author"/><br/>
<input type="submit" value="submit"/>
</form>
</body>
</html>

Code for preview.jsp



<%@ page isELIgnored="false" %> <%-- This is optional in case of jsp 2.0 --%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Author: ${param.author} <%= request.getParameter("author") %>
</body>
</html>

0 comments:

Post a Comment