Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need of Design Pattern with servlet

 
Hareesh Ram Chanchali
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I am writing a servlet which updates multiple database tables at once...
now I have a HTML front end file and a servlet. and I am printing the output about successful and unsuccessful insertion using out.print() where out is a PrintWriter to Response object of servlet

Total business logic is there in the servlet

My questions are

1. Is it possible for me to adopt MVC pattern for this

2. if not How I should organize my code...How to divide and place....

3.Where to keep the output info....
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Browser hits servlet (controller) and gets forwared to the JSP (view) with the form
  • User fills out form and submits. Form is submitted to the servlet.
  • Servlet parses form parameters. If OK, instanciates bean (model) and passes values to it. The bean has all the JDBC code in it.
  • The bean performs all database function and returns results (possibly in the form of another bean) to the servlet.
  • The servlet binds the results to the request object and forwards to the JSP for display.
  • The JSP (using either jsp:getProperty or EL, or JSTL..) presents the results to the user.

  •  
    Hareesh Ram Chanchali
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hi ben,

    I am updating 20 to 30 tables on a single click..
    It is an application of Data Population from MS-Excel file to Oracle...

    I wont fill the data in forms ...only the input i give is the file name with location... I should be able to display about successful/unsuccessful insertions rowwise
     
    Adeel Ansari
    Ranch Hand
    Posts: 2874
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Do as Ben directed. Then put some logic while inserting data in tables. You can populate a collection of a Bean, which would have appropriate message in it. Then bind that collection with your request object, and so forth. . . so forth.
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser Redhat VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You'll also want to look into a file upload library.
    I use http://jakarta.apache.org/commons/fileupload
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic