get head tag data

K

kapil

hello everyone...
i want to retrieve data that is available in between <head></head>
tag...in jsp using programming..
any one know that how to fetch that data..??

thanx in advance..
kapil..
 
S

Stanimir Stamenkov

Tue, 26 Apr 2011 11:15:51 -0700 (PDT), /kapil/:
i want to retrieve data that is available in between <head></head>
tag...in jsp using programming..
any one know that how to fetch that data..??

If you have the whole jsp content in a String variable, you could
use regular expression, e.g.:

String jspContent;
...
String headContent = jspContent
.replaceAll("(?s).*<head>(.*)</head>.*", "$1");
System.out.println(headContent);

You may read the java.util.regex.Pattern class documentation and the
Java Tutorial lesson on Regular Expressions for more info:

http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

http://download.oracle.com/javase/tutorial/essential/regex/index.html
 
J

John B. Matthews

Stanimir Stamenkov said:
Tue, 26 Apr 2011 11:15:51 -0700 (PDT), /kapil/:


If you have the whole jsp content in a String variable, you could
use regular expression, e.g.:

String jspContent;
...
String headContent = jspContent
.replaceAll("(?s).*<head>(.*)</head>.*", "$1");
System.out.println(headContent);

You may read the java.util.regex.Pattern class documentation and the
Java Tutorial lesson on Regular Expressions for more info:

http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

http://download.oracle.com/javase/tutorial/essential/regex/index.html

With some caveats: <http://stackoverflow.com/questions/1732348>.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top