aspose file tools*
The moose likes Servlets and the fly likes I'm really getting confused more and more... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "I Watch "I New topic
Author

I'm really getting confused more and more...

Todd Jaspers
Greenhorn

Joined: Aug 29, 2005
Posts: 23
Ok, I need to accomplish the following:

I basically have this web page with a series of fields on it. The fields contain everything from the person's name, to his payment information.

When the user clicks the submit button, it activates Javascript.

The Javascript I have stored in a seperate JS file. Basically, all that it does is validate several fields JUST to make sure that they aren't blank.


From THIS point, is where I'm confused. Up to that point, everything works fine. Anyway, from this point, I want to be able to take THREE of the values from three of the fields, and query a database on the host. The host will then return a TRUE or FALSE value. I will then use the true / false value, and if it's TRUE, I will confirm with a message box.


Now, what should I use? I thought maybe an Applet woudl work, but apparently I can't use an applet for this??? Do I need to use a Servelet?

I'm totally confused.

Someone please steer me in the right direction.


Thanks,

Todd
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Either a JSP page or a servlet is probably the best choice. Let's move this question to that forum.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

You need to go back to the server for DB access. You can do that by submitting a form on the page.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Todd Jaspers
Greenhorn

Joined: Aug 29, 2005
Posts: 23
Could someone explain to me exactly how this works?

Basically... I just want someone to be able to click a button on a web page.

This will take 3 fields, pass them to a Java application that will access a database, and then return a boolean value.

If the value is TRUE, then I want it to submit a string to a web site.


Is what I want to do a real difficult task? I've always been an applications programmer, and with that in mind, this seems like such a simple task, but I go to loads and loads of web pages that all seem to suggest that they have the answer, and I just get more and more confused. I understand how this all works, but damn... I'm getting really really frustrated. Can someone just piece this together for me?

If I write a JSP or a Servlet, does the web page have to be built "on the fly" by one of these? I will probably never update this page, so I could care less if it's static.

I just want to validate 3 fields from a database, that's ALL i want to do...


Thanks....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

You can submit a static page containing your 3 fields, but you need to submit it to something. If you want it to be Java (as opposed to a CGI language like Perl), then a servlet is the answer.

The servlet can retrieve the three values, do whatever DB machinations that need to be done (or better yet delegate that task to UI-agnostic business objects), and then....

Well, that's where your explanation breaks down. In a web app, requests don;t return values (such as the boolean that you cited), they return responses. That is, the "next" web page.

So, your users are on a page with these three fields. They click the submit button and your DB magic happens. Then what? What do you want to happen at that point?
Todd Jaspers
Greenhorn

Joined: Aug 29, 2005
Posts: 23
Originally posted by Bear Bibeault:
You can submit a static page containing your 3 fields, but you need to submit it to something. If you want it to be Java (as opposed to a CGI language like Perl), then a servlet is the answer.

The servlet can retrieve the three values, do whatever DB machinations that need to be done (or better yet delegate that task to UI-agnostic business objects), and then....

Well, that's where your explanation breaks down. In a web app, requests don;t return values (such as the boolean that you cited), they return responses. That is, the "next" web page.

So, your users are on a page with these three fields. They click the submit button and your DB magic happens. Then what? What do you want to happen at that point?




Thanks Bear, I appreciate the response in my emotional / dramatic state... hahah.

Basically, I'm making a payment posting page. Ultimately when everything is said and done, it will send an http request to a payment posting company with all the values in the URL.

Basically it will work like this:

1 - User goes to the payment posting page
2 - User enters in all the values in all the fields
3 - User clicks submit:
4 - Javascript activates and validates the fields to make sure they are not blank.
5 - If it passes the Javascript, I want it to then take three fields (account numbers for the patient).
6 - These three fields will be submitted to a database by means of a servlet (thanks)
7 - If the account number is valid, I was hoping it would somehow send a response back saying it was acceptable and asking the user to confirm (the confirm could be done with javascript on that page)
8 - If the account number was INVALID, I wanted it to popup saying it was invalid (maybe could also be done with javascript), and ask the user to re-enter the account number.

Does this sound possible?


Thanks Bear, I appreciate it.
Annie Smith
Ranch Hand

Joined: Mar 05, 2005
Posts: 172
Originally posted by Todd Jaspers:
Basically it will work like this:

1 - User goes to the payment posting page
2 - User enters in all the values in all the fields
3 - User clicks submit:
4 - Javascript activates and validates the fields to make sure they are not blank.
5 - If it passes the Javascript, I want it to then take three fields (account numbers for the patient).
6 - These three fields will be submitted to a database by means of a servlet (thanks)
7 - If the account number is valid, I was hoping it would somehow send a response back saying it was acceptable and asking the user to confirm (the confirm could be done with javascript on that page)
8 - If the account number was INVALID, I wanted it to popup saying it was invalid (maybe could also be done with javascript), and ask the user to re-enter the account number.

Does this sound possible?


IMO, this is possible. For the last two points, you could set a flag as a request attribute and forward using request dispatcher to the page. You could even have an alert message onLoad (in the BODY tag).

There are better (in terms of readable code) ways of doing this but I think this should go well.


Cheers!<br /><b>Annie</b>
Todd Jaspers
Greenhorn

Joined: Aug 29, 2005
Posts: 23
Thanks Annie, I appreciate it!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I'm really getting confused more and more...