R
roohbir
Hi,
I have a program in which I have a basic jsp page with a text field
and a submit button. The idea is that when a user enters his name and
hits the button it should take him to another page which displays
"Hello user".
I have made a JSP page but don't knwo how to connect it with the
servlet. The name of the servlet is MyOwnCustomTag. The servlet and
jsp page are displayed underneath:
<html><head><title>Registration Page</title></head>
<body>
<%@ taglib uri="/myOwnTLD" prefix="myowntag"%>
<form action="MyOwnCustomTag" method='post'>
<table>
<tr>
<td> Enter Name: </td>
<td><input type='text' size=15 name='name'
value='<myowntag:requestParameter property="name"/>'>
</td>
</tr>
</table>
</p>
<br>
<input type='submit' value='Submit'>
<input type='hidden' name='action' value='register-action'>
</form>
</body></html>
================================================================
import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
public class MyOwnCustomTag extends TagSupport {
private String property;
public void setProperty(String property) {
this.property = property;
}
public int doStartTag() throws JspException {
ServletRequest req = pageContext.getRequest();
String value = req.getParameter(property);
try {
pageContext.getOut().print("Hello " + value);
}
catch(java.io.IOException ex) {
throw new JspException(ex.getMessage());
}
return SKIP_BODY;
}
}
=========================================
Help would be really appreciated.
Ros
I have a program in which I have a basic jsp page with a text field
and a submit button. The idea is that when a user enters his name and
hits the button it should take him to another page which displays
"Hello user".
I have made a JSP page but don't knwo how to connect it with the
servlet. The name of the servlet is MyOwnCustomTag. The servlet and
jsp page are displayed underneath:
<html><head><title>Registration Page</title></head>
<body>
<%@ taglib uri="/myOwnTLD" prefix="myowntag"%>
<form action="MyOwnCustomTag" method='post'>
<table>
<tr>
<td> Enter Name: </td>
<td><input type='text' size=15 name='name'
value='<myowntag:requestParameter property="name"/>'>
</td>
</tr>
</table>
</p>
<br>
<input type='submit' value='Submit'>
<input type='hidden' name='action' value='register-action'>
</form>
</body></html>
================================================================
import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
public class MyOwnCustomTag extends TagSupport {
private String property;
public void setProperty(String property) {
this.property = property;
}
public int doStartTag() throws JspException {
ServletRequest req = pageContext.getRequest();
String value = req.getParameter(property);
try {
pageContext.getOut().print("Hello " + value);
}
catch(java.io.IOException ex) {
throw new JspException(ex.getMessage());
}
return SKIP_BODY;
}
}
=========================================
Help would be really appreciated.
Ros