Results 1 to 9 of 9

Thread: netbeans5.5.1

  1. #1
    Nishanthi is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Exclamation netbeans5.5.1

    i m developing a project reg the theater management i need to display the plan_layout of the theater for booking the tickets online so i thought of using check Box so that one person booked seat cannot be accessed by another pls tell me the coding for using it.....right now using Netbeans5.5.1 web application pls help me!!!!!

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What have you done so far?

  3. #3
    Nishanthi is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Exclamation netbeans

    i ve designed some forms for the administrator to add movies and delete movies from the theater now i have no idea of using check box for theplan layput of the theater........

    below is the coding for adding movie to theater

    /*
    * AddMovieServlet.java
    *
    * Created on October 6, 2009, 9:17 AM
    */

    package controller;

    import java.io.*;
    import java.net.*;
    import javax.annotation.Resource;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import java.util.LinkedList;
    import java.util.List;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.sql.DataSource;
    import java.sql.*;
    import java.sql.Date;
    import java.sql.SQLException;
    import java.sql.ResultSet;

    /**
    *
    * @author Owner
    * @version
    */
    public class AddMovieServlet extends HttpServlet {



    Connection con;
    PreparedStatement stat;


    RequestDispatcher rd;
    List error;


    private String MovieID;
    private String MovieName;
    private String Mcast;
    private String Intro;

    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    out.println("<h3> <a href='admins.jsp'>BACK</a></h3>");
    MovieID=request.getParameter("MovieID");
    MovieName=request.getParameter("MovieName");
    Mcast=request.getParameter("Mcast");
    Intro=request.getParameter("Intro");

    out.println("Movie ID = "+MovieID);

    out.println("Movie Name = "+MovieName);
    out.println("Cast = "+Mcast);
    out.println("Introduction = "+Intro);

    try
    {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:movie", "OWNER");
    stat = con.prepareStatement("Insert into SoundAndStageEntertainment1.Movie(MovieID,MovieNam e,Mcast,Intro) values(?,?,?,?)");
    stat.setString(1,MovieID);
    stat.setString(2,MovieName);
    stat.setString(3,Mcast);
    stat.setString(4,Intro);




    } catch (SQLException ex) {
    ex.printStackTrace();
    }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    try{

    processRequest(request, response);
    } catch (ServletException ex) {
    ex.printStackTrace();
    } catch (IOException ex) {
    ex.printStackTrace();
    } catch (SQLException ex) {
    ex.printStackTrace();
    }
    }

    /** Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    try{

    processRequest(request, response);
    }catch(Exception e)
    {
    System.out.println("Error"+e);
    }
    }
    }

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Don't try to generate HTML in servlets. Use JSPs for display.
    Also don't make connections instance variables of servlets. Declare them, use them and close them in one method wherever possible.

  5. #5
    Nishanthi is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Exclamation netbeans

    can u give example and explain please as i m new to this netbeans 5.5.1

  6. #6
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    6

    Default

    Java Code:
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    //PrintWriter out = response.getWriter();
    //out.println("<h3> <a href='admins.jsp'>BACK</a></h3>");
    MovieID=request.getParameter("MovieID");
    MovieName=request.getParameter("MovieName");
    Mcast=request.getParameter("Mcast");
    Intro=request.getParameter("Intro");
    request.setAttribute("movieid",MovieId);
    request.setAttribute("moviename",MovieName);
    request.setAttribute("mcast",Mcast);
    request.setAttribute("intro",Intro);
    /*out.println("Movie ID = "+MovieID);
    
    out.println("Movie Name = "+MovieName);
    out.println("Cast = "+Mcast);
    out.println("Introduction = "+Intro);*/
    
    try
    {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:movie", "OWNER");
    stat = con.prepareStatement("Insert into SoundAndStageEntertainment1.Movie(MovieID,MovieNam e,Mcast,Intro) values(?,?,?,?)");
    stat.setString(1,MovieID);
    stat.setString(2,MovieName);
    stat.setString(3,Mcast);
    stat.setString(4,Intro);
    stat.executeUpdate();
    con.close();
    rd=request.getRequestDispatcher("displaypage.jsp");
    
    
    } catch (SQLException ex) {
    ex.printStackTrace();
    rd=request.getRequestDispatcher("errorpage.jsp");
    }
    }
    Java Code:
    //displaypage.jsp
    -------------------
    <h3> <a href='admins.jsp'>BACK</a></h3>
    <%
      String movid=(String)request.getAttribute("movieid");
      String movname=(String)request.getAttribute("moviename");
      String mcast=(String)request.getAttribute("mcast");
      String intro=(String)request.getAttribute("intro");
    %>
    Movie id <%=movid%> <br>
    Movie Name <%=movname%> <br>
    Movie Cast <%=mcast%> <br>
    Intro <%=intro%> <br>
    Java Code:
    ----------------
    <h3> <a href='admins.jsp'>BACK</a></h3>
    Error occured while inserting records

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    And don't write Java code in JSPs either.
    It's 2009 not 1999.
    Use EL.

  8. #8
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    6

    Default

    Sir,

    Indeed its 2009, but any thing wrong at beginners level. I did not have any intention to misguide. Once the learner progress he/she will surely come to know about el.

  9. #9
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by dswastik View Post
    Sir,

    Indeed its 2009, but any thing wrong at beginners level....
    Yep. No need to learn the old (nightmare to maintain stuff).
    Especially when new it's best to start with best practices right away.

    P.S I'm taking my phone back to get a new one, see?

Similar Threads

  1. Replies: 1
    Last Post: 06-16-2009, 02:43 PM
  2. how to connect form to another form in netbeans5.5
    By Shivraj in forum AWT / Swing
    Replies: 1
    Last Post: 03-17-2009, 10:01 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
  •