• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prefill a web form

 
Joe Hertl
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I´m fairly new to Java and need help with a problem I´m unable to solve and so far all searches have turned up empty.
There is a webpage that contains a form. I have a java desktop application that stores a database with data I want to use to fill the form. The user scenario is as follows:
In the application:
1) The user opens the application and finds the desired row in database table.
2) The user clicks "open on website" button.
In the browser:
3) The webpage opens in a browser with the form already prefilled.
4) The user fills in captcha and clicks "submit" button on the webpage.
5) The result displays (just for the user to see, there is no parsing performed)

The problem is between steps 2 and 3. Is it even possible to open the website in a browser with the form already prefilled?

I have already tried htmlUnit, but failed, though that could be due to my inexperience. I cannot modify the webpage in question (it is run by state). Unfortunately, just submitting the form programatically and parsing the returned html page is not an option - the user always has to click "submit" button himself (in this case, actually, herself).

If it can help, this is the webpage in question: https://infodokument.justice.cz/erozhodnuti-web/index.html

Thanks in advance
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe, before coming to your presentation, on button click call a servlet which will have table values in response and fill those values in corresponding fields.
steps:
1. dont come directly to html page
2. give a link like https://infodokument.justice.cz/erozhodnuti-web/showForm
3. make a servlet showForm and set Attribute in request
4. dispatch that request to html page
5. fill all values in html.

I hope this will help you.
 
Joe Hertl
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. There is a problem though - likely caused by my inexperience - perhaps I do not understand what you meant by step 2, but I think you want me to modify the webpage in question (https://infodokument.justice.cz/erozhodnuti-web/). Unfortunately, I cannot do that, since I do not have the administrator rights for that webpage
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe, step 2 means create a servlet and give it url as showForm.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You *will* have to modify the page in question. You'll have to convert it from HTML to JSP in order to populate it dynamically. if you can't change the page, how do you propose to change the page? :-)
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do this client-side, but not from a stand alone application. You would need to create a browser plug-in that does the work. The plugin would probably read the HTML that comes in, read the values from your database, match database fields to the form fields, and inserts javascript at the end of the page which pre-fills the appropriate form fields.

See RoboForm (a password manager) as an example that proves you can do this with any page, as long as you have a browser plug-in installed. You could probably do the browser part using greasemonkey scripts (or similar) as long as you can get those scripts to communicate with your application.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic