I intend to build some translation-like web application where a user viewing a html page (which I had collected from the web and stored offline on the server side) and then the user will need to interact with the text inside this html, by selecting some subset of the characters (asking for translation-like operation)..
so the process here is divided to 3 parts:
- Extract the plain text from the html file
- The plain text will be pre-processed on the server and stored offline
- When the user selects a string online in the html, I need to identify the mapping in the plain text I had already extracted and stored offline.
For the plain-text-extraction I use jsoup.
and I had already pre-processed the plain files..
any ideas about the mapping part and identifying what text the user selected (or clicked)?
[Working on Java, Apache-Tomcat, JavaScript, linux ]
Related
I have and html template where i want to store whole html template along with user data in some directory?
Please let me know if there is any way?. Html template is as shown here.
in principle the HTTP request (from the HTML form) delivers the data entered by the user. I would save that separately (common practise is obviously a DB, but you can also save as JSON file in a directory).
You can always load the HTML and fill the data you need on-the-fly.
If you really want to save the HTML with the data, on your backend you need to get the actual HTML source and manipulate it to add the user data in each field.
Hi I have jsp page That is having some text fields,I will fill that text fields and I will submit that form to server side.If any error comes in the server side I will redirect to the same page with error message Now I want that text field to remain as it is but in my case it is clearing.How to make the text field as same.
The two options available to you are:
Don't reload the page. Instead submit the data via AJAX or validate it by javascript. That way you don't ever have to touch the data in the form. Make sure your javascript highlights the fields that have errors in some way.
The endpoint that you're POSTing your data to needs to be able to recognise that the data is invalid and include that data when returning the user to the same page. I'm not familiar with jsp, but generally you'd do that by including variables in your template for your form that could contain the data, and passing empty strings on the first load of the page. If the page is then shown to the user again after a failed form validation, pass back the POST data that you received in your form request.
There are two option, you can dispatch the request/response to the same page instead of redirect, but you need to add an attribute and recover it in the JSP, or you can add the attribute in the session , recover the value to de text field and remove it using (if you are using JSTL)
I'm testing an existing website and I need to pick up the url of a link and the href text = "#".
If I click on the link, whatever it is opens then displays a perfectly normal URL in the browser, so the website is somehow translating "#" into a proper URL. I have several hundred items, all referenced by "#", but all opening completely different items when you click on them.
I need to know what it is before I click it as I have to be able to handle it opening as a pop up or in a separate window or as a load instruction to office etc. and therefore pass the URL to different bits of code to open, depending on the file extension.
I've tried:
teststring = "//div[#class='" + divClass.toString() + "']/div[2]/a";
LesTestString = driver.findElement(By.xpath(teststring)).getAttribute("href");
which returns 'myWebsite.com/my/path/here/#'; and
String LessLink = inputhandler.getAttribute("href");
which does the same.
when I look at the element in firebug it looks like this:
<div class="reference span5 ">
<a class="name math-formula" href="#"> 1.1 Lesson Player </a>
Any suggestions?
Added Information: It would seem that the URL is generated by the browser on click from various bits of information sent in a large Json string. So this questions should now be either (1) how do you pick up the url generated by the browser onclick, or (2) how do you pick up the Json sent from the server using java /selenium or something that will run in that environment?
I'm using a Struts 2 app with Tomcat 6 server using JDK 1.7. We support more than 15 languages. I've a form which sends an email, with 2 issues:
When I type any Japanese or Korean characters in the form and submit it, the email body contains all ????????
I have a captcha on the form page. If I enter an invalid captcha for Japanese or Korean and click submit, it comes back to the same page, retaining username, email, etc. However, the retained characters are corrupted and do not remain in the same language in which they're entered. However, this happens only for Japanese and Korean.
I have this line in my JSP at the very top of the page:
<%# page contentType="text/html; charset=UTF-8"%>
Also, server.xml has a connector element which specifies URIEncoding="UTF-8"
These 2 issues are not present in other languages. Can any one tell me what am I missing?
Thanks!
The encoding problem seems to happen after you submit the form, in the code that prepares the email and sends it. Does your email program allow you to look at the raw data of the email? What's the (declared) encoding of the email? Can you have your email app choose an encoding? (And in which case make sure that UTF-8 is selected)?
I want an HTML form to send email.
In it I have dropdown list(course).On selecting course,i want checkboxes with labels that are branches of the course selected.
How to create add attachment button(i mean backend coding that will insert a new file tag onto the page)
Waiting for ur replies.
I dont know AJAX,Jquery etc.
I know Java(jsp,servlet),html,javascript.
Simple answer for pure HTML: you can't.
When you don't want to send emails like so Send Mail, which would open the user's email client to send it manually. You will need an php server in the back which is able to send emails.
If you want to do it with JSP
http://www.java-samples.com/showtutorial.php?tutorialid=675
This tutorial also provides file upload, or better for you it provides finished code:
http://www.oop-reserch.com/scheduler_example_1.html
http://www.java-tips.org/java-ee-tips/javaserver-pages/how-to-send-e-mail-through-jsp.html
HTML forms don't do much other than, when submitted, send the inputs they contain back to the server in the for of an HTTP POST.
In order to display the checkboxes in response to the select input (dropdown list) changing you've got two options:
make an AJAX call that gets the values for the checkboxes from the server, modifying the DOM when the response is received (this will be by far the better user experience).
submit the form and generate a new page based on the value of the select input (dropdown list).
Once the form contains the inputs required to send the mail it can be submitted, resulting in an HTTP POST at the server. You'll need to read the input values and send the mail using JavaMail.
With regards to the attachment, you need to first get the uploaded file (Apache Commons can help you there) then attach the file to the mail as explained here.