• 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

POST data w/o form?

 
Greenhorn
Posts: 10
Netbeans IDE PHP Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically I'm wondering if there is a way to send POST data without actually using a form. I ask this because what I want to do is take data from a text area ans seperate it then send the values to a page that currently takes data from seperate form fields.

I only want to do this because I already have the page that gets the results for the request it just currently take data differently. I'm new to this so if I could just use the existing page and feed data into it rather than make a new one it would be great.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not exactly sure what you are trying to accomplish by your description, but be aware that hacking around is likely to create more confusion that just doing things in a straight-forward manner.

That said, the only other way to generate a POST from a browser other than a form is via Ajax.
 
Vincent Micchia
Greenhorn
Posts: 10
Netbeans IDE PHP Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:I'm not exactly sure what you are trying to accomplish by your description, but be aware that hacking around is likely to create more confusion that just doing things in a straight-forward manner.

That said, the only other way to generate a POST from a browser other than a form is via Ajax.



I understand. What it basically is is that I have a existing ability on my site to do this, but want a user to be able to submit the information in a different way.

Currenty a user can enter a item and a quantity(only 10 of these at the moment each with their own text box), then these get sent to a page that displays the result. What I want to do is let the user enter the information in a text area via comma seperated values (so they can use as many as they want at once) but still come to the same results page. So for that to work I need to parse the data from the text area and then send it with the same POST values as the individual text boxes would have had.

New to this so that seems like the simplest way but perhaps not so much.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's the simplest way only if you think the users are going to type correctly-formatted data 100% of the time. Which, of course, they aren't. So now you have to write some code to parse the CSV data and deal with the cases where they didn't put in enough fields into a row. Maybe they hit the period instead of the comma, or maybe they accidentally put in two commas together, or put everything into a single line because they didn't understand (or read) the instructions. And so on. Not the simplest way at all.
 
Bear Bibeault
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
I think that you may be digging yourself a very deep, very dark, and very dangerous hole.

What is the motivation for this in the first place? Do you have a requirement to allow CSV data entry? I can't imagine any user wanting to enter data in that way -- seems rather silly. But what's the reason for the whole task?
 
Vincent Micchia
Greenhorn
Posts: 10
Netbeans IDE PHP Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well it's a precursor to allowing excel data to be imported. But this is faster and works for the time being. Users have been asking for something like this so yeah here I am.
 
Bear Bibeault
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
Seems to me that a better solution would be to refactor the original servlet to use a lower-level API that both forms of input could share. How are you planning on validating the CSV?
 
Vincent Micchia
Greenhorn
Posts: 10
Netbeans IDE PHP Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Seems to me that a better solution would be to refactor the original servlet to use a lower-level API that both forms of input could share. How are you planning on validating the CSV?



Well I can't validate the first value in each line other than it being there. The second value had to be a number snd I was hoping I could make sure there were no more than 2 values before the \n if that is possible.

Edit: was going to split the values into and array first and then check every other value for the needed validation.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vincent Micchia wrote:Well it's a precursor to allowing excel data to be imported. But this is faster and works for the time being. Users have been asking for something like this so yeah here I am.



You might consider skipping over the quick-and-dirty method, then, and going straight to working with Excel uploads. I'm doing that right now, as it happens; extracting data from Excel and validating it in a servlet isn't too bad, but you have to have something of a framework in place if you're going to be dealing with multiple formats. One thing you could try (which I haven't done yet) is to provide empty Excel spreadsheets with macros which control what can be entered where. You still have to do the same validation on the server, but your users will thank you if they can be sure they can just upload their spreadsheet and be sure it contains valid data.
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
If your aim is to send some post data without form submiting you can use ajax for that or you can submit your form to iframe so your total page will not be refresh.
 
Vincent Micchia
Greenhorn
Posts: 10
Netbeans IDE PHP Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I wrote it in php because I'm considerably more familiar with that but it would seem that I'm not going to be able to do it that way. Any help turning this into jsp would be much appreciated.



Edit: removed code for displaying the array don't need that was just for testing.
 
Vincent Micchia
Greenhorn
Posts: 10
Netbeans IDE PHP Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aslo as a side note. The code that this form data gets submitted to does all the validation and error checking already. For me it's really just getting the data in the correct format (form field post data.)
 
I found some pretty shells, some sea glass and this lovely tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic