Originally Posted by
Petr
I think If you won't explain about your task, nobody can't help you. Do you have any code?
Thnx for replying..
heres code::
AddEmpServlet::
package com.servlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class AddEmpServlet extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String uname=req.getParameter("uname");
String pass=req.getParameter("pass");
out.println("<html><body>");
out.println("<center> Mysite </center>");
out.println("<a href='addEmp?uname="+uname+"'>AddEmp</a><br/>");
out.println("Welcome: "+uname);
out.println("<center><forn action='addEmp'>");
out.println("Emp No:<input type=text name=emp no/>");
out.println("<input type=submit value=AddEmp/>");
out.println("</form></body></html>");
}
};
LoginServlet::
package com.servlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class LoginServlet extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
String uname=req.getParameter("uname");
String pass=req.getParameter("pass");
System.out.println("uname" +uname);
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<html><body>");
out.println("<center> Mysite </center>");
out.println("<a href='addEmp?uname="+uname+"'>AddEmp</a><br/>");
out.println("<a href='ViewEmp?uname="+uname+"'>ViewEmp</a>");
out.println("Welcome: "+uname);
out.println("</body></html>");
}
};
xml::
<web-app>
<servlet>
<servlet-name>LS</servlet-name>
<servlet-class>com.servlets.LoginServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>AS</servlet-name>
<servlet-class>com.servlets.AddEmpServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LS</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AS</servlet-name>
<url-pattern>/AddEmpServlet</url-pattern>
</servlet-mapping>
</web-app>
One login.html File::
Dir Structure::
│ AddEmpServlet.java
│ Login.html
│ LoginServlet.java
│
└───WEB-INF
│ web.xml
│
└───Classes
└───com
└───servlets
AddEmpServlet.class
LoginServlet.class
Got error when tried to access "http://localhost:8080/B/login.html"