slip_java

Upload: akrati-gupta

Post on 05-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 slip_Java

    1/7

  • 8/2/2019 slip_Java

    2/7

    2

    // Here you put the check on the username and password

    if (username.toLowerCase().trim().equals("akrati") &&

    password.toLowerCase().trim().equals("123")) {

    %>

    Welcome :

  • 8/2/2019 slip_Java

    3/7

    3

    2. Create a servlet that will return an html page to the client containingcourse details such as course name and course fees in a tabularformat.

    import java.io.*;

    import javax.servlet.*;

    import javax.servlet.http.*;

    public class CourseServ extends HttpServlet

    {

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws

    IOException, ServletException

    {

    res.setContentType("text/html");

    PrintWrit er out = res.getWrit er();

    out.println("Info");

    out.println("");

    out.println("Course Name");

    out.println("Course Fees");

    out.println("core java3000");

    out.println("adv java5000");

    out.println("");

    out.println("");

    }

    }

  • 8/2/2019 slip_Java

    4/7

    4

    3. Write a java program to display actor (name, movie) details specifiedby the user using jsp

    Actor.jsp

    Enter the Details

    Welcome

    Enter Actor name:

    sEnter Movie:

    Disp.jsp

  • 8/2/2019 slip_Java

    5/7

    5

    4. Create a html page which contains a list of colors and it shoulddisplay the selected color in the next page using servlets also changethe background with selected color.

  • 8/2/2019 slip_Java

    6/7

    6

    5. Create a servlet that will count the number of times a clientcontaining the webpage (use session tracking)

    import java.io.*;

    import javax.servlet.*;

    import javax.servlet.http.*;

    import java.util.*;

    publicclass SessionDemo extends HttpServlet

    {

    publicvoid doGet(HttpServletRequest request, HttpServletResponse response)

    throws ServletException, IOException {

    HttpSession session = request.getSession(true);

    response.setContentType("text/ html");

    PrintWriter out = response.getWrit er();

    Integer count = new Integer(0);

    String head;

    if(session.isNew()) {

    head = "This is the New Session";

    } else {

    head = "This is the old Session";

    Integer oldcount =(Integer)session.getValue("count");if(oldcount != null) {

    count = new Integer(oldcount.intValue() + 1);

    }

    }

    session.putValue("count", count);

    out.println("\n" +

    "" + head + "\n" +

    "\n"

    + "\n"+" Information TypeSession Count \n"

    +"\n" +" Total Session Accesses\n" +

    "" + count + "\n" +

    "\n"

    +"" );

    } }

  • 8/2/2019 slip_Java

    7/7

    7

    6. Write a JSP program that accepts the patient details from user anddisplay the details on the next page.

    Pat.jsp

    Enter the Details

    Welcome

    Enter Pat name:

    sEnter Pat Id:

    Disp.jsp