Extract text file with HTML tags from JTextPane
hello world
I have a big problem !
I am creating an applet with a JTextPane ...
so I can write text, (bold, italic etc), i can insert images.
Now i want to create a text file with all the HTML tags
corresponding to what I wrote in my JTextPane.
I want to have and save the HTML file corresponding to what i wrote ...
Is it possible ? Help me please ....
Jeremie
writing to a file from an applet is going to take a fair amount of work on your part.
in order to write to a file from your applet, you have to use servlets or jsp to write to a file on your server. if you wish to write locally, look into signing your applet or policy settings of your browser.
for writing to a file to the server, i suggest you look into servlets and tomcat to run the servlets.
i just finished a project that used servlets and they take some time to figure out, but its definitely worth your time.
here are some websites...
http://www.j-nine.com/pubs/applet2servlet/Applet2Servlet.html
http://jakarta.apache.org
other websites have tutorials that you can look at too
Andy
Similar Messages
-
Parsing text file with SGML tags
<EMAIL>
<ADDRESS>>[email protected]
<DESC>>Email your questions to Click Here to E-mail
<POP>
<ADDRESS>N/A
<ZIP>N/A
How do you parse above text file which has SGML tags ? thanksOh, sorry, if it's not an XML-file, then you properbly should use another approach. Where does the file come from? Could you properbly make it be a xml file ? ;-)
Possible approaches are:
* StringTokenizer, possibly with returning delimiters option enabled
* good old make-it yourself indexOf/substring-method, ok... complicated
* if you would like to handle the contents exactly like xml you could add a <?xml version="1.0"?><root> in the beginning and a </root> in the end and still use an xml parser, but keep character encodings in mind here.
* another quite simple way that properbly fits best is java.util.regex API. if you want to use it, I can give you the code. it's easy.
regards
sven -
How to Read a program with HTML tags from SO10
Hi All,
I have a html program in Standard text (SO10).But when I am trying read the program content using FM: READ_TEXT, the html tags <b> </p> etc are creating problem.
They are retrieved as <(><<)>b>.
What should we do to get same/original text as in SO10? Is there any other FM for that? Any other way to achieve this?
Thanks & Regards,
Vimalan Ramhere is the code sample.
after reading the text using READ_TEXT you have to use CONVERT_ITF_TO_ASCII to convert the contents.
DATA: itf_tab TYPE STANDARD TABLE OF tline ,
wa_itf TYPE tline .
DATA: c_datatab TYPE tdtab_c132 .
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'ST'
language = sy-langu
name = 'Y_RAJA_HTML'
object = 'TEXT'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER = HEADER
TABLES
lines = itf_tab
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
EXPORTING
* CODEPAGE = '0000'
* FORMATWIDTH = 72
language = sy-langu
tabletype = 'ASC'
* TAB_SUBSTITUTE = ' '
* LF_SUBSTITUTE = ' '
* REPLACE_SYMBOLS = 'X'
* REPLACE_SAPCHARS = 'X'
IMPORTING
* FORMATWIDTH_E = FORMATWIDTH_E
* X_DATATAB = X_DATATAB
c_datatab = c_datatab
* X_SIZE = X_SIZE
TABLES
itf_lines = itf_tab
EXCEPTIONS
invalid_tabletype = 1
OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards
Raja
Message was edited by: Durairaj Athavan Raja -
Regex: Extracting text between two HTML tags
Hello,
the common answer to this question would be
<tag>(.*)</tag>
or
<tag>[^<]*But I have LFs (and whitespace) around the tags:
<html>
<body>
One text line to be retrieved.
</body>
</html>So I tried
(?s)<body>(.*)</body>But that didn't help.
What's missing?Thanks for your replies.
@Sabre
I tried your suggestion with the following code to no avail
import java.util.*;
import java.util.regex.*;
public class X {
public static void main(String[] args) {
String s=
"<html>\n"+
" <head>\n"+
"\n"+
" </head>\n"+
" <body>\n"+
" One <u>text line</u> to be retrieved.\n"+
" </body>\n"+
"</html>";
String regex= "<body>([^<]*)</body>";
Pattern p = Pattern.compile(regex); // Create the pattern.
Matcher matcher = p.matcher(s); // Create the matcher with the string.
while (matcher.find()) {
System.out.printf("Found: \"%s\" from %d to %d.%n",
matcher.group(), matcher.start(), matcher.end()-1);
}@ejp
Paul had a similar objection. But as I've written, my html string will always have this same structure and all I have to do is to extract the text. So if regex doesn't work in that case, I'd rather prefer two indexOf-s instead of bothering a parser. -
Tablespace usage report generated with html tags instead of text
Hi ,
We have a unix shell script scheduled to find tablespace usage and sends the report to our mail id.
For the past few weeks(no changes idone in the script) the report is coming with html tags instead of text as below.
</head>
<body>
<p>
<table border='1' width='90%' align='center' summary='Script output'>
<tr>
<th scope="col">
TABLESPACE_NAME
</th>
<th scope="col">
CUR_USE_MB
</th>
<th scope="col">
CUR_SZ_MB
</th>
<th scope="col">
CUR_PRCT_FULL
</th>
<th scope="col">
FREE_SPACE_MB
</th>
<th scope="col">
MAX_SZ_MB
</th>
<th scope="col">
OVERALL_PRCT_FULL
</th>
</tr>
<tr>
<td>
SYSTEM
</td>
<td align="right">
268
</td>
<td align="right">
500
</td>
<td align="right">
54
</td>
Is this any settings issue or anything to be modified in the script.Could you please reply..
Regards,
Bharath.
Edited by: 870384 on Jul 6, 2011 1:17 AMHi Sven W,
Please find the sql below that is generating the tablespace usage report. In the staring of the script markup is set to ON and at the end it is set to OFF.Do you suggest any changes to this..?
SET ECHO OFF
SET PAGES 999
SET MARKUP HTML ON SPOOL ON
col tablespace_name format a15 trunc
col cur_use_mb for 999999999
col cur_sz_mb for 999999999
col free_space_mb for 999999999
col max_sz_mb for 999999999
compute sum of cur_use_mb on report
compute sum of cur_sz_mb on report
compute sum of free_space_mb on report
compute sum of max_sz_mb on report
break on report
spool tablespace.html
select tablespace_name,
round(sum(total_mb)-sum(free_mb),2) cur_use_mb,
round(sum(total_mb),2) cur_sz_mb,
round((sum(total_mb)-sum(free_mb))/sum(total_mb)*100) cur_prct_full,
round(sum(max_mb) - (sum(total_mb)-sum(free_mb)),2) free_space_mb,
round(sum(max_mb),2) max_sz_mb,
round((sum(total_mb)-sum(free_mb))/sum(max_mb)*100) overall_prct_full
from (select tablespace_name,sum(bytes)/1024/1024 free_mb,0 total_mb,0 max_mb from DBA_FREE_SPACE group by tablespace_name
union select tablespace_name,0 current_mb,sum(bytes)/1024/1024 total_mb,sum(decode(maxbytes, 0, bytes, maxbytes))/1024/1024 max_mb
from DBA_DATA_FILES group by tablespace_name) a group by tablespace_name;
select owner,segment_name,segment_type,bytes/(1024*1024) size_m
from dba_segments
where tablespace_name = 'SYSTEM' and segment_name='FGA_LOG$' order by size_m desc;
spool off;
SET MARKUP HTML OFF SPOOL OFF -
Remove HTML tags from a text area
Hi, here is my problem:
I have a form with a text area item; this item is “Display as Editor HTML standard”. So it is possible to enter formatted text with tags HTML. Then I save the text in a table. In the column the text maintain the HTML tags. Afterwards I can put the text in a report, and I can see the formatted text with the tags HTML interpreted.
But I need also to use that text for other aims, (i.e. sending it in a mail) with the html tags removed.
Is there any way to remove HTML tags from a text item?
Regards
DarioFrom http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:769425837805
FUNCTION str_html (line IN VARCHAR2)
RETURN VARCHAR2
IS
x VARCHAR2 (32767) := NULL;
in_html BOOLEAN := FALSE;
s VARCHAR2 (1);
BEGIN
IF line IS NULL
THEN
RETURN line;
END IF;
FOR i IN 1 .. LENGTH (line)
LOOP
s := SUBSTR (line, i, 1);
IF in_html
THEN
IF s = '>'
THEN
in_html := FALSE;
END IF;
ELSE
IF s = '<'
THEN
in_html := TRUE;
END IF;
END IF;
IF NOT in_html AND s != '>'
THEN
x := x || s;
END IF;
END LOOP;
RETURN x;
END str_html;There's also a reqular expression approach that I've not tried. Remove HTML Tags and parse the text out of it -
Reading dilimited input from a text file with tokenizer
i am trying to read in a text file with the following structure: 2 integers on each line with comma as the delimitor.
i am using the BufferedReader stream and Tokenizer to detect ",".
try {
BufferedReader in = new BufferedReader(new FileReader(filename));
//read in the data file
while ((s = in.readLine())!= null) {
int i = 0;
for (i = 0; i < 100; i++) {
t = new StringTokenizer(s,",");
A1 = Integer.parseInt(t.nextToken());
catch (IOException e) {System.err.println(e);}
When i print out A1[i], it only reads the last line of the text file. Please tell me what's wrong.
Also i'd really like A1[i] to store the integer before the comma and another array A2[i] to store the integer after the comma. Please help.
Thanks.
p.s. A1 and A2 are arrays...when i previewd message in Netscape 7 it left out the brackets and the index....What is the for i loop for? If it is to read the next line from the file, then the while loop has taken care of it. Other than this there should be no problem with the rest of the code.
Just add another line to store the next token into A2. -
How to create PDF from text file with specific layout?
I wanted to create the pdf from text file in specific layout - Landscape orientation and JIS B3 Page size while at Adobe Acrobat Pro.
In past, I could do a right click on a text file (desktop area) and select print to print out the document into .pdf BUT only if I set the Adobe PDF to Landscape and JIS B3 Page size BEFORE. And I could only do 15 text documents at once.
I wanted to see if I could do the create the pdf from text file with specific layout in Adobe Acrobat without having to go to Control Panel to preset the Adobe PDF to specific layout at every time. I would have to set Adobe PDF back to normal layout after I'm done with these pdf print outs. I do lots of pdfs in normal layout. Sometimes I would forget to do that.
So, How do I do that?No such luck. It would output the contents in letter size even in JIS B3 Page layout at MS word.
Is there a script or action where I could set the orientation and page size before creating PDF on these text files? -
Text in internal table with HTML tags.
Hi ,
I have Text in internal table with HTML tags.
The text has to be shown in output of smartform as formatted text.
That is the smartform should READ the HTML TAGS , convert the text accordingly and show in the output as formatted text.
I dont want to make a webform . This is for NORMAL SPOOL output and NOT for WEB OUTPUT.
IN SHORT
:- the text in the internal table is like this ( please ignore the dot in the HTML TAG )--
<html><.U>this is heading</.U>Line with no break<.br>some content text</.br>
</html>
OUTPUT
<U>this is heading</U>Line with no break<br>some content text</br>
1) Can I can get the output and store it as text in a string variable and show in the smartform ?
In this case I want to know how to convert and store in a variable in sap .
OR
2) Can the text element convert the text with HTML TAGS to html formatted output and show it ?
Regards,
JagatHi,
Use the FM SCP_REPLACE_STRANGE_CHARS and check
See the
Converting html special characters to plain characters (e.g. u00FC to u00FC) -
How do I set BI Publisher to read html tags from the database?
How do I set BI Publisher (Release 10.1.3.4) to read html tags from the database? For example if the text is quoted with a bold tag I want my output to display the text in bold. Is there a setting or something I can set?
I took a look at Tim Dexter's blog as suggested and the sample worked, but for the elements in the xml file not for the value coming from the database, however this is good to know as well!
I have data in the data base column which looks like this:
'MS Applied <B(bold tag)> Mathematics</B(bold tag)>University of Southern California'
I want the data to be rendered like this:
'MS Applied <B>Mathematics</B> University of Southern California'.
In Report Builder on the property sheet I would set Contains HTML Tags property to Yes and the report would render correctly.
In BI Publisher 10.1.3.4 I can not seem set it to read this I have change the configure properties of the report to Character set to HTML and Make HTML output accessible to True. I just can't figure out what I'm missing.
Thank you for any assistance you can offer. -
How to exlcude HTML Tags from Excel Reports
Hi Guys
Within Project Online - OData extract to Excel
Has anyone found a way to eliminate the HTML tags from Multi Line Text fields within Project Server? I can easily extract the text and generate nice Excel Reports, but the html tag is very annoying in the Excel Reports and it doesn't read easily.
Any help would be appreciated.
Marc Soester [MVP] http://marcsoester.blogspot.comMarc,
What you could do (given that you find the required time and energy to write the lines),
would be to replace all (!) html characters like here (http://stackoverflow.com/questions/14705605/remove-html-tags-from-cell-strings-excel-formula -
this is one of the Excel UDF/VB-based solutions, but will not refresh in Excel Services - however there is a good list of what to replace) with PowerQuery.
That would refresh over a PowerBI subscription in the least..
-Ville -
How to print a text file with pagebreak.......
hi to all,
i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon.hi to all,
i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon. -
How to send a mail with HTML body from Oracle
Hi Team,
Can somebody guide me how to send a mail with HTML body from oracle.
Here is the piece of code i am trying to send a mail.
procedure SEND_MAIL is
cursor c_1 is select * from table_name;
l_mail_id varchar2(40);
-- ls_mailhost VARCHAR2(64) := Mailhost;
ls_from VARCHAR2(64) := ‘[email protected]’
ls_subject VARCHAR2(200);
ls_to VARCHAR2(64);
l_mail_conn UTL_SMTP.connection;
ls_left_menu_name VARCHAR2(64);
ll_emp_num number(8);
begin
for i in c_1 loop
begin
l_mail_conn := UTL_SMTP.OPEN_CONNECTION('IP');
UTL_SMTP.HELO(l_mail_conn, 'IP');
UTL_SMTP.MAIL(l_mail_conn, LS_FROM);
UTL_SMTP.RCPT(L_mail_conn, LS_TO);
UTL_SMTP.DATA(l_mail_conn,'From: ' ||ls_from || utl_tcp.crlf ||
'To: ' ||ls_to || utl_tcp.crlf ||
'Subject: ' ||ls_subject|| utl_tcp.crlf);
UTL_SMTP.QUIT(l_mail_conn);
exception
when no_data_found then
null;
when others then
RAISE_APPLICATION_ERROR(-20000, 'Failed to send mail due to the following error: ' || sqlerrm);
end;
end loop;
end;
ThnxHi Nicolas!
Have you tried to set "Output Format" for "RAW Text" to HTM in SCOT.
If HTM is missing in your dropdown-list, you could check out table SXCONVERT2. Copy the line with category T/format TXT, and change the format from TXT to HTM. The existing function
SX_OBJECT_CONVERT__T.TXT does not need to be changed. Now you should be able to choose HTM in SCOT. You will probably need som HTML-tags in your text to make it look good.
Hope this helps!
Regards
Geir -
Stripping all HTML tags from a CLOB
Hi all,
Running Oracle 9.2.0.8 on AIX...
We have a table which stores HTML document fragments in a clob. I have a requirement to convert these to plain/text (strip all HTML tags) for sending in a plain/text email body.
I have read the following solution from Tom Kyte's site:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:25695084847068
Basically creating an Oracle text index on the CLOB column and calling ctx_doc.filter with "plaintext" parameter set to true.
I noticed in Tom's example, he uses the default filter, which based on the docs, is NULL_FILTER, which applies no filtering. I have tried his example in my dev box, creating the text index on the CLOB column with no parameters.
The call to ctx_doc.filter did not filter the html at all. I re-created the index and specified the INSO_FILTER and the filtering was done. I was under the impression that INSO_FILTER was for filtering binary content to plaintext...
create table filter ( query_id number, document clob );
create table demo
( id int primary key,
theclob clob
create index demo_idx on demo(theClob) indextype is ctxsys.context;
SET DEFINE OFF;
Insert into DEMO
(ID, THECLOB)
Values
(1, '<html><body><p>This is a test of <strong>ctx_doc.filter</strong> and plaintext filtering.</p></body></html>');
COMMIT;
exec ctx_doc.filter('demo_idx',1, 'filter',1, true);The above code does not convert the html to plaintext...
Now re-create with the index with INSO_FILTER
drop index demo_idx;
create index demo_idx on demo(theClob) indextype is ctxsys.context parameters ('filter ctxsys.inso_filter');
exec ctx_doc.filter('demo_idx',1, 'filter',1, true);Above scenario returns string "This is a test of ctx_doc.filter and plaintext filtering."
The ORacle documentation doesn't specify any special filter parameter that needs to be set... just wondering if I'm missing soemthing here... or better yet, if there is a better solution to my problem. ;-)
Thanks
StephaneThe difference between what you did and what Tom Kyte did is that you created your index on a clob column and Tom created his index on a blob column. What I don't know is why that makes a difference. I have demonstrated below with one blob column and one clob column, one index on the blob and one index on the clob, using the same code on both, with different results.
SCOTT@orcl_11gR2> create table filter
2 (query_id number,
3 document clob)
4 /
Table created.
SCOTT@orcl_11gR2> create table demo
2 (id int primary key,
3 theblob blob,
4 theclob clob)
5 /
Table created.
SCOTT@orcl_11gR2> create index demo_blob_idx
2 on demo (theblob)
3 indextype is ctxsys.context
4 /
Index created.
SCOTT@orcl_11gR2> create index demo_clob_idx
2 on demo (theclob)
3 indextype is ctxsys.context
4 /
Index created.
SCOTT@orcl_11gR2> insert into demo values
2 (1,
3 utl_raw.cast_to_raw (
4 '<html>
5 <body>
6 <p>
7 This is a test of
8 <strong> ctx_doc.filter </strong>
9 and plaintext filtering.
10 </p>
11 </body>
12 </html>'),
13 '<html>
14 <body>
15 <p>
16 This is a test of
17 <strong> ctx_doc.filter </strong>
18 and plaintext filtering.
19 </p>
20 </body>
21 </html>')
22 /
1 row created.
SCOTT@orcl_11gR2> exec ctx_doc.filter ('demo_blob_idx', 1, 'filter', 1, true)
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> exec ctx_doc.filter ('demo_clob_idx', 1, 'filter', 2, true)
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> select id, utl_raw.cast_to_varchar2 (theblob), theclob from demo
2 /
ID
UTL_RAW.CAST_TO_VARCHAR2(THEBLOB)
THECLOB
1
<html>
<body>
<p>
This is a test of
<strong> ctx_doc.filter </strong>
and plaintext filtering.
</p>
</body>
</html>
<html>
<body>
<p>
This is a test of
<strong> ctx_doc.filter </strong>
and plaintext filtering.
</p>
</body>
</html>
1 row selected.
SCOTT@orcl_11gR2> select query_id, document from filter
2 /
QUERY_ID
DOCUMENT
1
This is a test of ctx_doc.filter and plaintext filtering.
2
<html>
<body>
<p>
This is a test of
<strong> ctx_doc.filter </strong>
and plaintext filtering.
</p>
</body>
</html>
2 rows selected.
SCOTT@orcl_11gR2> -
Text Catalog showing HTML tags
We are having an issue after applying Bundle #22 for HCM 8.9 where the calls to the Text Catalog are now showing HTML tags. Has anyone else seen this? Im trying to figure out if its the bundle or something maybe with our customizations that have affected this change. Basically the page where the text from the text catalog displays now shows not only the text, but raw HTML tags as well on the page. Example: BR, B
Thanks!
Edited by: CoryU on May 11, 2010 2:00 PMWe are having an issue after applying Bundle #22 for HCM 8.9 where the calls to the Text Catalog are now showing HTML tags. Has anyone else seen this? Im trying to figure out if its the bundle or something maybe with our customizations that have affected this change. Basically the page where the text from the text catalog displays now shows not only the text, but raw HTML tags as well on the page. Example: BR, B
Thanks!
Edited by: CoryU on May 11, 2010 2:00 PM
Maybe you are looking for
-
Upgraded to 10.7 camera is no longer recognized
I guess I can restarting again, but basically I plug in my Nikon 2500 and it doesn't matter if I start iPhoto before or after. The camera never shows up, not in iPhoto, not in Finder, not on the desktop. I took another picture, it has a specific butt
-
HELP! Macbook pro external hard drive not showing up
Hello I really need help and I've already read through all the relevant threads non of them helped. Here's my problem. And please read all of it cause its frustratingly weird. I have a few external drives. Suddenly, with out me changing or downloadin
-
I purchase iTunes Match. When I applied it to my iphone5, it erased my music library. Even when I restored my backup, the library was not there. I still have all of the music on my ipad2. I thought that iTunes Match would allow me to put my libra
-
Digital signatures won't print in a PDF form emailed to me. PLEASE HELP!
I've been trying to print some documents emailed to me in PDF format. On my monitor, the entire document shows up fine, INCLUDING THE SIGNATURES, however when I print them, the form is printed WITHOUT the VERY NECESSARY signatures! PLEASE help! I'
-
Hi there. I've got a strange problem with my servlet. The servlet is used to open files from my database. I use tomcat 5.5 an it wroks perfectly fine when a call the servlet through the address http://localhost:8080/xxxxx but when i try to open a non