we can do like : in a html file : <BODY> <FORM METHOD=POST ACTION="SaveName.jsp"> What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR> What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR> What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4> <P><INPUT TYPE=SUBMIT> </FORM> </BODY>
then a jsp file like
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <% String name = request.getParameter( "username" ); session.setAttribute( "theName", name ); String email = request.getParameter("email"); session.setAttribute("email", email ); String age = request.getParameter( "age" ); session.setAttribute("age", age);
The setProperty with the wildcard (*) was a convenience method for loading a bean with all the parameters in a given form. It's not used much these days.
On of the big disadvantages to coding everything in JSP scriptlets is that the code can't be run/tested outside of the JSP environment. When you start to factor your functionality back from JSPs into beans and plain old Java objects (POJOs) you gain the ability to work with the logic from the command line before worrying about how it will work in a web environment. You can also automate a lot of the testing with tools like JUnit.
In general JSP has moved past useBean tags and scriptlets altogether. These days, it is expected that your control logic will be performed in a servlet and all of your model codeing will be done in POJOs. After all this is done, context is passed to the JSP where (using the newer JSTL and EL) the JSP performs only markup tasks.