• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

conversion of html to java

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
I have html form where the data is going to be filled, what i want is? I want to convert this data into an xml format using java or It is possible to transfer the data from html to java objects where i got the structure of that form.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you do a POST on your HTML form, the browser sends the form fields to the server. If you have a servlet there, you can take the values and make XML by building strings or building a DOM and exporting it to string or whatever makes your day.
I briefly worked on one system where the buttons on forms did not do POST, but ran JavaScript in the browser that generated XML, put the XML into a hidden field on another form, and finally posted that form. Whew. That way their server saw only XML, never the form fields.
Did that make sense?
 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an idea off the top of my head:
Create your javabean, but along with the usual getter & setter methods, have a setter method for each property that accepts a string, and knows how to convert the string to whatever type it is.
in your HTML form, name each field exactly as the javabean property is named, also put a hidden field in the form with the classname of the javabean.
Make a filter (which runs before servlets) that goes through all the request data, and
1) gets an new instance of the javabean based on the classname field.
2) for each parameter,
2a) looks for a method named set[ParameterName] that accepts a String
2b) invokes that method on the bean, passing it the ParameterValue
3) puts the object in the request attributes/context
and then when it gets to the servlet, have the servlet extract the bean.
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic