i'm new to java struts.
actly i want to create an application in which i want to search within the website static pages,which has no database. i.e. if user enter the search string then the corresponding results are shown to user.
You should probably start with a Struts tutorial (http://j2ee.masslight.com/Chapter4.html for example) to get the bones of your application up and running, namely your textbox and button.
Struts is an MVC framework with a 'M'. By that I mean the implemention of your model is completely up to you. So when it comes time to write your Action class you can do anything you want. From the sounds of it you want parse an HTML file so you can either load it using java.io if it's stored on the server or load it from where ever.
It depends on your definition of a 'database'. There are some good search engines out there (like Lucene) that can index your html and store this in an index file on your file system. The semantics come in on whether you believe this index is a 'database' or not.
Most of the search engines come with an HTML crawler and parser out-of-the-box so your requirement to have something search through your content (especially when it is not publicly available to be indexed by the likes of Google), should not be insurmountable.
Related
So if you want to take input from an html form and put that into a database, you can have the form's action direct to a php file like example.php. That php file can then manage database calls with like mysqli_connect() and whatnot.
My question is, what is the equivalent of this when you want to use a Java back end instead? Do I have the form's action direct to a .java file? I know how to use Hibernate for databases, but I don't know how to connect the input from the web form to my Java code.
I have no clue what terms to even google for. I tried "java back end tutorial" but that wasn't useful at all. I'd appreciate any simple explanations, or even the correct technologies to look up.
You can develop Web application and Web site with Java. Google it and you will see a lot of tutorials on how to do it.
The initial technology to develop Web apps with Java is Servlet or JSP as said above by user2963623.
i have a word document with a form that is filled by users and , after that, it is saved. I would like to access form field data from a Java application in order to automatize some business process.
I have tested Apache POI but it is unabled to access form elements.
Is there some api to access form element data with java?
You can use: Class FFDataBaseAbstractType (org.apache.poi.hwpf.model.types).
The FFData structure specifies form field data for a text box, check box, or drop-down list box.
You may try Aspose.Words for Java which allows you to access form fields and data in Java applications. The API is quite simple and easy to use. The component is a simple Jar file which is easy to deploy with your application. Also note that you do not need to install MS Word in order to use this component. Please see if this might help in your scenario.
Disclosure: I work as developer evangelist at Aspose.
Trying to provide a user with editable XML page in a browser.
For example, the following is part of an XML.
<Employee name="John Doe" type="contract" ID="1000">
<Salary>10000</Salary>
<Email>johndoe#johndoe.com</Email>
</Employee>
When the above is presented to the user in a brower (either IE or FF), the user should be able to highlight an attribute or the value. When highlighted and the second mouse button is pressed, this would pop up a menu for editing. For attributes and tags, it could be something like ID-TEST-PRESENT or ID-TEST-OPTIONAL. Now instead of ID, the attribute should change to ID-TEST-PRESENT when selected.
Likewise, for values, a text box can be presented, where the user can enter a new value. Then this updated XML file needs to be sent to the back end and saved.
Is this doable? If yes, what would be the easiest way.
I have always written embedded applications. This is my first foray on the web browser side. Any help is appreciated.
It is doable of course, but it's not trivial. At least not for someone who is not used to Javascript and manipulating the DOM. You would have to parse the XML and create a HTML document with Javascript event listeners on each element.
You could try and use an existing component and modify it if necessary. I found a similar question here:
https://stackoverflow.com/questions/378205/web-xml-editor-with-xml-syntax-highlighting
Unless you are dealing with generic XML files, you are probably better off just reading the XML and generate a standard HTML form. The simplest way would be to base everything on a database that will export to XML to the backend processes if needed. This makes it much simpler to add/edit multiple rows of data
One way to to create an interface for editing information in a particular XML vocabulary is to use XForms. (I think it is by far the easiest and best, but YMMV.) Given an appropriate infrastructure (see below), using XForms for what you describe would involve:
Write a form, using XHTML + XForms. Specify editing widgets for the parts of the XML you want the user to be able to edit; make other parts of the XML read-only (or don't display them at all). Define how you want the edited data to be submitted. Style using CSS.
When the user opens the form, the XForms processor loads the XML document automatically and provides editing widgets as specified in the XForm you specified in step 1. The user edits.
When the user clicks on the submit button, the browser sends the data back to the server as XML, and software on the server performs the necessary validations (this is user input from the open web, you do want to check it) and processes it appropriately.
As you can see, it's a little simpler than rolling your own using AJAX (at least once you have the infrastructure set up).
What infrastructure is necessary for XForms depends in part on which XForms implementation you are using.
For client-based implementations of XForms (such as XSLTForms from AgenceXML, or Formula from EMC), you need (a) a copy of the software on your server (in the case of XSLTForms, this means one XSLT stylesheet, one Javascript library, and one CSS file), (b) possibly an appropriate link in the form itself (how this needs to be done varies with the implementation), and (c) a server willing to accept PUT requests. In some contexts, it will be (c) that is the hardest to get set up, but any server that provides a WebDAV interface will do, so SVN with auto-versioning, Apache (alone or on top of Subversion), and other tools can all be used.
For server-based implementations (such as Orbeon Forms or BetterForm), you need to install the XForms implementation and run it on your Web server; since they are typically servlets, you will need to put them in a servlet engine. In general, they will ship with some form of WebDAV server included.
Steven Pemberton of W3C and CWI has written a helpful tutorial introduction to XForms; I maintain a list of pointers to that and to other XForms-related materials that may also be helpful.
In order to do this you would need to work a lot. To do generic editing you would need the following
XML parser at back end to parse XML file to 2 formats (A) To convert to the required HTML format for front end. (B) To convert into a required backend format. This is tricky and requires some thought. A brute force method is easy but very inefficient.
Setup an AJAX connection to your script which can take and recognize parts of the XML. For this you will need some mechanism to identify the part... may be an ID passed though HTML.
The interface for AJAX should the update the Database/file and do the needful.
This is a simple layout. It needs a lot of work to be done. Do some research
item
codemirror seems to be the best one
The jquery.xmleditor might be what you are looking for. They offer a graphical UI for editing XML. For the text-based XML editor, they rely on the Cloud9 editor. Be aware that Cloud9 is GPL licensed.
LiveXMLEdit is more an explorer-like editor, but maybe it helps, too
AXEL is a library for creating XML authoring applications based on document templates.
I am helping someone out with a javascript-based web app (even though I know next to nothing about web development) and we are unsure about the best way to implement a feature we'd like to have.
Basically, the user will be using our tool to view all kinds of boring data in tables, columns, etc. via javascript. We want to implement a feature where the user can click a button or link that then allows the user to download the displayed data in a .doc file.
Our basic idea so far is something like:
call a Java function on the server with the desired data passed in as a String when the link is clicked
generate the .doc file on the server
automatically "open" a link to the file in the client's browser to initiate the download
Is this possible? If so, is it feasible? Or, can you recommend a better solution?
edit: the data does not reside on the server; rather, it is queried from a SQL database
Yep, its possible. Your saviour is the Apache POI library. Its HWPF library will help you generate Microsoft word files using java. The rest is just clever use of HTTP.
Your basic idea sounds a bit Rube-Goldbergesque.
Is the data you want in the document present on the server? If so, then all you need to do is display a plain HTML link with GET parameters that describes the data (i.e. data for customer X from date A to date B). The link will be handled on the server by a Servlet that gets the data and produces the .DOC file as its output to be downloaded by the browser - a very simple one-step process that doesn't even involve any JavaScript.
Passing large amount data as GET/POST around might not be the best idea. You could just pass in the same parameters you used to generate the HTML page earlier. You don't even need to use 3rd party library to generate DOC. You could just generate a plain old HTML file with DOC extension and Word will be happy to open it.
Sounds like Docmosis Java library could help - check out theonline demo since shows it something similar to what you're asking - generating a real doc file from a web site based on selections in the web page. Docmosis can query from databases and run pretty much anywhere.
I'm trying to write a program that takes company names from a text file and searches them on a search engine website (SEC's Edgar search). Each search usually comes up with 1-10 unique search result links and so I want to use curl to click on the link with the relevant company name. The link page has a brief summary with the term "state of incorporation:" and then the state name. Im hoping to parse the state name. I am having trouble understanding how to use HTML parsing and curl and their classes. I would appreciate any help possible such as a brief outline of steps or just any advice at all. Thanks.
Assuming that the HTML is fairly basic, use something like the Mozilla Java HTML Parser. The getting started guide will give you more details on creating the DOM. Java has builtin APIs for downloading content from the web, and these will likely be sufficient for you (rather than using "curl").
Once you have a DOM, you can use the standard DOM APIs to navigate for the links and items that you want.