Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: jdbc jsp servlet integration

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default jdbc jsp servlet integration

    Jdbc-servlet-jsp integration

    Your current task is to insert Employee details at least 10 records into database and showing inserted results into the browser.

    Things need to done:

    Step 1: To insert details create one jsp with the following fields :

    1.Employee.jsp:-
    Employee Id(textbox)
    Employee Name (Text box)
    Designation (Dropdown)
    Salary (textbox) ----- If you want to add any field then you can add it.

    Note: - [Dropdown options like: Trainee Engineer, Software Engineer, Tech lead etc...]

    2.EMPLOYEE Table :

    Column Name Type Not Null Constraints Comments
    Eid Number Yes Primary Key -
    Ename Varchar2(50) Yes - -
    Designation Varchar2(50) Yes - -
    Sal Number Yes -

    3. EmployeeServlet: this is the servlet where you can get the User interface details regarding the Employee and establishes the connection with the database, execute your queries ,setting your result set in request scope and displaying the results in results.jsp


    Note: I recommend separate layer (class) to write the database logic so create one class to interact with the database and you can use the class in servlet by creating the object of the class

    Example :

    Class EmployeeServlet
    {
    service(-----)
    {
    EmployeeDao empDao=new EmployeeDao();
    empDao.insertEmployee(--);
    ResultSet rs=empDao.retrieve(--);
    }
    }












    4.EmployeePojo.java :
    I recommend its better to create this class to set all the user interface details to one object and pass this object to EmployeeDao


    For Example :

    service(-----)
    {
    String eid= request.getParameter(“eid”);

    Employee empObj = new Employee();
    empObj.setEid(eid); etc...
    EmployeeDao empDao=new EmployeeDao()
    empDao.insertEmployee(empObj);
    }
    5.EmployeeDao :

    It contains connection logic and user defined methods to insert and retrieve the records.

    6.result.jsp: it displays the result in table format


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: jdbc jsp servlet integration

    I've moved this thread to the JSP forum.

    That's NOT how this works. All you've done is dump your homework here with no explanation of what you've tried or where you're stuck. That's extremely rude. Please read the link in my signature on asking questions the smart way before you post again.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: jdbc jsp servlet integration

    i dont know how to post .ok i not able to understand it.i created table of database.one jsp page containg details of the employee and one servlet to connect the details with the database .can u suggest exactly what it is.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: jdbc jsp servlet integration

    Did you read the link on asking questions the smart way? More recommended reading: http://www.javaprogrammingforums.com...e-posting.html
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: jdbc jsp servlet integration

    Thank you for ur kind suggestions.They helped me alot.I completed the work as required and eventhough it had some warnings.i will check out those problems and fix them.Once again thanks for your help.They help me not even now and in future also.

  6. #6
    Junior Member
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: jdbc jsp servlet integration

    Hello,

    I need to let users interact with my web application so they can insert their personal comments.

    I store these comments (with line breaks, tabs, spaces...) in a mysql DB, but when I get them from DB and display in JSP, no line breaks, tabs or spaces are shown...(I'm using Struts 2 < s : property value="comment"/>)

    If I look how the comments are stored in DB (e.g with SqlDeveloper) I can see the line breaks, tabs and spaces

    anybody knows how to solve this problem??
    thanks in advance

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: jdbc jsp servlet integration

    Quote Originally Posted by saurus View Post
    Hello,

    I need to let users interact with my web application so they can insert their personal comments.

    I store these comments (with line breaks, tabs, spaces...) in a mysql DB, but when I get them from DB and display in JSP, no line breaks, tabs or spaces are shown...(I'm using Struts 2 < s : property value="comment"/>)

    If I look how the comments are stored in DB (e.g with SqlDeveloper) I can see the line breaks, tabs and spaces

    anybody knows how to solve this problem??
    thanks in advance
    Start your own thread. You aren't going to get much attention just adding your question as a reply to another one.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. JDBC Error in servlet
    By shuklagirish in forum Java Servlet
    Replies: 2
    Last Post: May 30th, 2011, 08:13 AM
  2. Problem with the servlet and jdbc
    By manjukdvg in forum Java Servlet
    Replies: 3
    Last Post: September 8th, 2010, 08:44 AM
  3. Continuous Integration (vs)
    By ssgeejr in forum Java Theory & Questions
    Replies: 5
    Last Post: May 14th, 2010, 07:26 AM
  4. Euler integration
    By Kakashi in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 2nd, 2009, 04:19 PM
  5. JNDI - JDBC Integration problem
    By rangarajank in forum JDBC & Databases
    Replies: 0
    Last Post: September 29th, 2009, 06:07 AM