Dear Sir,
I have two queries.
First question is:
I have a Html page. On which Have two buttons Submit and Issue.
I want when I click on Sumit button request should be go to submit.jsp. and When I click on Issue button then request should be go to Issue.jsp.But When I click on submit button request do to Issue.jsp.
Second Question is How I reterive the input parameter of html page to submit.jsp.
Please review..
My files are:
login.html:
[code=html]
<html>
<head>
<title>A simple JSP application</title>
<head>
<body>
<form method="get" action="tmp">
Name<input type="text" name="user">
<br>
Password<input type="password" name="pass">
<input type="Submit" value="Submit">
<input type="Submit" value="Issue">
</form>
</body>
</html>
[/code]
LoginServlet.ja va:[code=java]
import java.io.*;
import javax.servlet.* ;
import javax.servlet.h ttp.*;
import java.sql.*;
import java.util.*;
public class LoginServlet extends HttpServlet{
public void doGet(HttpServl etRequest request, HttpServletResp onse response)
throws ServletExceptio n,IOException{
try
{
response.setCon tentType("text/html");
PrintWriter out=response.ge tWriter();
String user=request.ge tParameter("use r");
String pass=request.ge tParameter("pas s");
out.println("He llo: "+user);
out.println("He llo: "+pass);
RequestDispatch er dispatcher1 =
request.getRequ estDispatcher("/Issue.jsp");
dispatcher1.for ward(request,re sponse);
RequestDispatch er dispatcher =
request.getRequ estDispatcher("/submit.jsp");
dispatcher.forw ard(request,res ponse);
}
catch(Exception e)
{
e.printStackTra ce();
}
}
}[/code]
web.xml:[code=xml]
<web-app>
<servlet>
<servlet-name>one</servlet-name>
<servlet-class>LoginServ let</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>one</servlet-name>
<url-pattern>/tmp</url-pattern>
</servlet-mapping>
<jsp-file>submit.jsp </jsp-file>
<jsp-file>Issue.jsp</jsp-file>
<url-pattern>*.do</url-pattern>
<welcome-file-list>
<welcome-file>Login.html </welcome-file>
</welcome-file-list>
</web-app>[/code]
I have two queries.
First question is:
I have a Html page. On which Have two buttons Submit and Issue.
I want when I click on Sumit button request should be go to submit.jsp. and When I click on Issue button then request should be go to Issue.jsp.But When I click on submit button request do to Issue.jsp.
Second Question is How I reterive the input parameter of html page to submit.jsp.
Please review..
My files are:
login.html:
[code=html]
<html>
<head>
<title>A simple JSP application</title>
<head>
<body>
<form method="get" action="tmp">
Name<input type="text" name="user">
<br>
Password<input type="password" name="pass">
<input type="Submit" value="Submit">
<input type="Submit" value="Issue">
</form>
</body>
</html>
[/code]
LoginServlet.ja va:[code=java]
import java.io.*;
import javax.servlet.* ;
import javax.servlet.h ttp.*;
import java.sql.*;
import java.util.*;
public class LoginServlet extends HttpServlet{
public void doGet(HttpServl etRequest request, HttpServletResp onse response)
throws ServletExceptio n,IOException{
try
{
response.setCon tentType("text/html");
PrintWriter out=response.ge tWriter();
String user=request.ge tParameter("use r");
String pass=request.ge tParameter("pas s");
out.println("He llo: "+user);
out.println("He llo: "+pass);
RequestDispatch er dispatcher1 =
request.getRequ estDispatcher("/Issue.jsp");
dispatcher1.for ward(request,re sponse);
RequestDispatch er dispatcher =
request.getRequ estDispatcher("/submit.jsp");
dispatcher.forw ard(request,res ponse);
}
catch(Exception e)
{
e.printStackTra ce();
}
}
}[/code]
web.xml:[code=xml]
<web-app>
<servlet>
<servlet-name>one</servlet-name>
<servlet-class>LoginServ let</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>one</servlet-name>
<url-pattern>/tmp</url-pattern>
</servlet-mapping>
<jsp-file>submit.jsp </jsp-file>
<jsp-file>Issue.jsp</jsp-file>
<url-pattern>*.do</url-pattern>
<welcome-file-list>
<welcome-file>Login.html </welcome-file>
</welcome-file-list>
</web-app>[/code]
Comment