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 HTML, CSS and JavaScript and the fly likes Have two forms, want one of them to be displayed as if it was inside the other 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 » Engineering » HTML, CSS and JavaScript
Bookmark "Have two forms, want one of them to be displayed as if it was inside the other" Watch "Have two forms, want one of them to be displayed as if it was inside the other" New topic
Author

Have two forms, want one of them to be displayed as if it was inside the other

Jhon Salchichon
Greenhorn

Joined: Sep 12, 2012
Posts: 10
Hello greenhorns!


The title might be confusing... the problem is the following:

I'm making a register page for a web site, so i have the usual things like nick, email, name, surname, date of birth, profile image, etc.
As far as i know it's not possible to make only one form to handle files(profile image) and text at the same time, so i had to make two forms, one of them has the profile image and the other form has the rest(all the fields and a button to complete the registration). The problem is that i want the profile image form to be displayed between the date of birth and the finish button(which are both in the other form...).

Is there any way to accomplish this?

Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Jhon Salchichon wrote:As far as i know it's not possible to make only one form to handle files(profile image) and text at the same time...


I don't quite understand this. What do you mean by a "form to handle files"?
Jhon Salchichon
Greenhorn

Joined: Sep 12, 2012
Posts: 10
Paul Clapham wrote:
Jhon Salchichon wrote:As far as i know it's not possible to make only one form to handle files(profile image) and text at the same time...


I don't quite understand this. What do you mean by a "form to handle files"?



As far as I know it is not possible to make a form to upload files and text at the same time..
If it's possible please guide me!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Jhon Salchichon wrote:As far as i know it's not possible to make only one form to handle files(profile image) and text at the same time

This is not correct.

A single form with an encoding type of multi-part must be used when uploading files, and the form can contain any other input elements.

See the JspFaq for info on handling such forms.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Oh, a file upload form? Sure, it can contain more fields than just the file. But what kind of guidance are you looking for? You already know how to make a file upload form, you already know how to make a form with several input fields, so it should be easy enough to make a file upload form with several input fields.
Jhon Salchichon
Greenhorn

Joined: Sep 12, 2012
Posts: 10
The problem with this is that in the servlet i do: request.getParameter("someParameter") and it returns null(for my text parameters)... that's because of the enctype="multipart/form-data", if i delete that line all works fine...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yes, that's true. In this particular case you don't get the parameters like that.

Instead, you get them exactly the same way you get the file upload. All of the parameters should be accessed in the same way.

I have always used the Apache FileUpload product to handle this sort of thing. Unfortunately the only examples I have of it personally are in my work computer and I won't be looking at that until Monday. But at any rate start with the plan of getting the string parameters in the same way as you're already getting the file upload parameter.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Have two forms, want one of them to be displayed as if it was inside the other
 
Similar Threads
Sending value of input-form to two pages
I two easy question fix
Multiple actionerror tags problem
Two forms in a page problem
Question about multiple forms on a page sharing a bean