Results 1 to 1 of 1
  1. #1
    javalad90 is offline Member
    Join Date
    Jan 2014
    Posts
    5
    Rep Power
    0

    Default Connect a servlet to another Java File?????

    I have no clue if this is possible or not, but I have to follow a 3-tier structure which I have been told that using a servlet does not count as a 3 tier but rather 2 tier. I have a jsp file which connects to a servlet which is fine. But is there a way to connect my servlet file to another java file?

    // My JSP CODE

    <!DOCTYPE html>
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

    <link rel="stylesheet" href="css/style-new.css" type="text/css" />
    <title>Login</title>
    </head>
    <form name ="loginform" action="login" method= "post">
    User name <input type="text" name="username" size="10"> Password <input type="password" name="password" size="10"> <input type="submit" value="Sign In" size="10">
    </form>
    <br>

    </body></html>


    // My servlet code

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**
    * Servlet implementation class please
    */
    @WebServlet("/please")
    public class please extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public please() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    String un = request.getParameter("username");
    String pw = request.getParameter("password");

    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    }

    }
    Last edited by javalad90; 04-02-2014 at 03:12 PM.

Similar Threads

  1. Replies: 0
    Last Post: 08-14-2013, 04:12 PM
  2. cant connect to servlet
    By yemista in forum Java Servlet
    Replies: 3
    Last Post: 08-18-2012, 05:18 PM
  3. connect servlet and jsp in tomcat
    By abcdef in forum Java Servlet
    Replies: 1
    Last Post: 02-18-2011, 12:04 PM
  4. J2EE = Servlet+Mysql connect
    By initmax in forum Java Servlet
    Replies: 2
    Last Post: 10-30-2009, 09:42 AM
  5. J2EE = Servlet+Mysql connect
    By initmax in forum Java Servlet
    Replies: 2
    Last Post: 10-30-2009, 07:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •