For smart Primates & ROBOTS (oh and ALIENS ).

Showing posts with label xml. Show all posts
Showing posts with label xml. Show all posts

Wednesday, March 18, 2015

Change Search in This Blog size

Problem:

If you have a blog owner in blogger and used the "Search in This Blog" widget, you can see this size is very large and taking lot of spaces in your blog

Solution:



Use below code at the end of your blogger XML file

<script>
function r_search() {
var r_place_s=&quot;h2&quot;;
var r_place_t=&quot;h5&quot;;
var Attribution1=document.getElementById(&quot;CustomSearch1&quot;);
var Attribution1_html=Attribution1.innerHTML;
var regex = new RegExp( &#39;(&#39; + r_place_s + &#39;)&#39;, &#39;gi&#39; );
Attribution1.innerHTML=Attribution1_html.replace( regex, r_place_t );
}
r_search();
</script>

Share:

Saturday, July 19, 2014

Post Xml data without form in JSP and receive

How to post xml data in JSP page without form field and get it's data
in the next JSP page.

The first file post-data.jsp is just taking xml data form xml file and
sending xml data as a post to the get-post.jsp page.

first file is:

post-data.jsp
--------------
< %@ page import="java.net.*" % >
< %@ page import="java.io.*" % >
< %@ page import="java.util.*" % >
< %@ page import="java.text.*" % >
< %
try
{
URL u;
u = new URL("http://localhost:9292/post/get-post.jsp");
// get the xml data from xml file which you want to post
String inputFileName="C:\\temp1.xml";
FileReader filereader =new FileReader(inputFileName);
BufferedReader bufferedreader=new BufferedReader(filereader);
String initial=bufferedreader.readLine();
String finalData=new String();
while(initial!=null)
{
finalData=finalData+initial;
initial=bufferedreader.readLine();
}
String s=(finalData.toString());
HttpURLConnection uc = (HttpURLConnection)u.openConnection();
uc.setRequestMethod("POST");
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setRequestProperty("Content-Type", "text/xml; charset=\"utf-8\"");
uc.setAllowUserInteraction(false);
DataOutputStream dstream = new DataOutputStream(uc.getOutputStream());
dstream.writeBytes(s);
dstream.close();
InputStream in = uc.getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuffer buf = new StringBuffer();
String line;
while ((line = r.readLine())!=null) {
buf.append(line);
}
in.close();
out.println(buf.toString());
}
catch (IOException e)
{
out.println(e.toString());
}
% >


Second file is:

get-post.jsp
-----------------

< %@ page import="java.util.*" % >
< %
String postedData = request.getReader().readLine();
///// perform here your operation for postedData
out.println("Posted Data is ");
out.println(postedData);
% > 
Share:

Ads Inside Post

Powered by Blogger.

Archive