• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bean or Servlet

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a form with 3 inputs (Firstname, LastName and Job Title).

I need to search a MySQL database and find information with 1 or more of the fields entered in.

Please advise if this should be done using a JSP for the Form input page and a Servlet for the action page that searches the database? If so can someone provide a quick psuedo Servlet code?

Or should I do it with a JSP for the Form and use a Bean for the action page?
[ July 07, 2006: Message edited by: Joseph Smithern ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you can't submit to a bean at all. If you are talking about submitting to a JSP that employs a bean, then that's possible, but ill-advised.

Your processing should occur (or be controlled by) a servlet.

Please read this article on web app structure, paying particular attention to the PRG pattern.
[ July 07, 2006: Message edited by: Bear Bibeault ]
 
Joseph Smithern
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

I read and printed out that article and will use it.

Last week I completed a form that uses a JSP that employs a Bean and it works great with my form offering three fields where 1 or more form entries can search for information in my database.

My next step is to create a JSP form page for entering and modifying the database and I will use Servlet for the action page which I assume is the correct way to do that.

Please advise what negative effects I could possibly have with my current JSP search page that employs a Bean?

Here is how the JSP calls the Bean that is working for me:


[ July 09, 2006: Message edited by: Joseph Smithern ]
[ July 09, 2006: Message edited by: Joseph Smithern ]
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jsp is for presention purpose so as far as posible keep Buisness logic in this case DataBase conn in servlet.
As jsp doesn't have good exception handling.

So in Above case From every request code is fetching first name ,Last Name . inStead of keep employee object (i.e Employee bean as Your using) in request.
 
Joseph Smithern
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would just need to remove the URL property where I am connecting to the database and put that in my Bean and my JSP will then fully seperate Presentation from Business?
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I would just need to remove the URL property where I am connecting to the database and put that in my Bean and my JSP will then fully seperate Presentation from Business?



No. You'll have to do have a Servlet receive the request, instantiate the bean, set the bean properties from request and then call database operation methods on it, retrieve the result, set the result as a scoped attribute, and finally forward to a jsp.

ram.
reply
    Bookmark Topic Watch Topic
  • New Topic