This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP form with four inputs and one submit button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP form with four inputs and one submit button" Watch "JSP form with four inputs and one submit button" New topic
Author

JSP form with four inputs and one submit button

lisy jessica
Ranch Hand

Joined: Oct 27, 2010
Posts: 47
Hi Everyone,

I need help to solve this problem, i want to search database based on 4 inputs, 2- form inputs and 2- selectboxes and one submit button in a JSP page....I am stuck here....please can anybody plzzz help me out :) , Just give me some idea or simple sample code would be great. This is very urgent for me.

Thanks in advance
Lissy.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60806
    
  65

This doesn't seem to have much to do with JSP. Once the form is on the browser, it's just HTML.

The form action should address a servlet that can collect the submitted information and pass it to a model class that can perform the database manipulations.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
lisy jessica
Ranch Hand

Joined: Oct 27, 2010
Posts: 47
Thanks for the quick reply.....got some idea..will try.

Thanks
Lissy.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Do post a specific problem if you have one. We can move the post appropriately based on the area you need help in.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
lisy jessica
Ranch Hand

Joined: Oct 27, 2010
Posts: 47
Hi

I tried this but not able to get it, I need to retrieve data from db based on 2 form inputs and 2 selectboxes with one submit button... here is my code

AutoAssign.jsp



retrieve.jsp



This code is not working...when i enter the values and click submit ...it gives me "sorry couldn't find data"...Please anyone lookinto my code and tell me ..where the prob is...I am really stuck. I even tried with servlet...but same output(Sorry couldn't find data). Please help me.

Thanks in advance
Lissy.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
Standard responses
1 - Don't use scriptlet code in JSP. Java code belongs in servlets/beans.
2 - The JDBC-ODBC bridge driver is . I suggest getting a real database, with a supported JDBC driver (MySQL, Oracle, MSSql...)
3 - When constructing sql statements with strings, you leave yourself open to sql injection attack. Instead your sql should use prepared statements to pass in the users values.

Specific to this code.
- You need to match up the names of your controls with the request parameters you are looking for.

For instance you have:


CABINET/EXCHANGE/TER <> Cabinet

The control "name" and the request parameter being retrieved must match.
I would suggest renaming the input components on AutoAssign.jsp to match what you have in the getParameter() calls in retrieve.jsp.

Suggested debugging steps
- print out the values of the search fields on your results page so that you can see they came through correctly.
- print out the sql generated to execute. Try running it on your database, and see what you get. Fiddle with it until you get sql that works, and then try translating the changes back to your code.

Things to think about
- are all your search parameters necessarily used to run the query? Particularly the remarks column will restrict the results too much I would think.
- consider writing the query logic into a java class. This code sample is based on patterns from 10 years ago. We've come a long way since then.


lisy jessica
Ranch Hand

Joined: Oct 27, 2010
Posts: 47
Thanks for the quick reply...will try this and get back to you.

Thanks
Lissy.
jhon masco
Ranch Hand

Joined: May 13, 2010
Posts: 93

Hey lisy, here a simple tutorial. It will help you to understand better the Stefan's advices.
lisy jessica
Ranch Hand

Joined: Oct 27, 2010
Posts: 47
Hey Guys,

I got it....Thanks alot for the help. This is the best forum

Thanks
Lissy.
 
wood burning stoves
 
subject: JSP form with four inputs and one submit button
 
Similar Threads
populate the form field with the submitted input
error with jsp:foward
object doesn't support this property or method
input from a new window
Three forms in jsp page