david arnold

Ranch Hand
+ Follow
since Apr 10, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by david arnold

Thank you Bear for the clarification! It is not for google, but for a third party service. I got the response I need by using Apache HttpClient, GetMethod and getMethod.getResponseBodyAsString().

Thanks again for all the help, really appreciate!!

Regards.
10 years ago
Thank you guys for the info. The response i got is the complete HTML page.

This is the first time I use this. There is a service that I could get a json by inputting the URL (http://server/function.do?JSONv2&get&number=561979) in the address bar of the browser, I get response which is a Json string. So I thought if I use HTTP GET method with the same URL send by the API, I will get the response as a Json string as well.
10 years ago
I am expecting to get the response body, the response content from the server. For example, i am expecting the google search result content in the second method.
10 years ago
Hi,

In eclipse I have a java class to implement a HTTP GET function to get expected response, tried two ways, one is Apache HTTP api, the other is JavaURLConnection, both methods return the HTML page code, not the expected response I need. It is weird and would appreciate if anyone could help.





Response:

result:::<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/google_favicon_128.png" itemprop="image"><title>testtesttest - Google Search</title><style>#gb{font:13px/27px Arial,sans-serif;height:30px}#gbz,#gbg{position:absolute;white-space:nowrap;top:0;height:30px;z-index:1000}#gbz{left:0;padding-left:4px}#gbg{right:0;padding-right:5px}#gbs{background:transparent;position:absolute;top:-999px;visibility:hidden;z-index:998;right:0}.gbto #gbs{background:#fff}#gbx3,#gbx4{background-color:#2d2d2d;background-image:none;_background-image:none;background-position:0 -

............................................................
cript type="text/javascript">google.ac&&google.ac.c({"agen":true,"cgen":true,"client":"heirloom-serp","dh":true,"ds":"","eqch":true,"fl":true,"host":"google.com","jam":0,"jsonp":true,"msgs":{"cibl":"Clear Search","dym":"Did you mean:","lcky":"I\u0026#39;m Feeling Lucky","lml":"Learn more","oskt":"Input tools","psrc":"This search was removed from your \u003Ca href=\"/history\"\u003EWeb History\u003C/a\u003E","psrl":"Remove","sbit":"Search by image","srch":"Google Search"},"ovr":{},"pq":"testtesttest","qcpw":false,"scd":10,"sce":5,"stok":"4JYSbUsW73C-IQw1E6CZqUkJvCo"})</script></body></html>
10 years ago
Thank you Gregg. That is what I did, I could make the element (div) change the height (50px to auto) by clicking a button. The issue is that when div is 50px height, if i have 5 lines text, the fourth and fifth lines are below the bottom border, which i tried to hide it.

I tried using , which change the five lines to one line, not what i want for this case. I guess I need javascript method to calculate the charactor and show n charactor only at the height 50px, wondering if there is better ways to do it??
12 years ago
JSF
Hi,

i have a text in a span which is in a fixed height/width div, well, if the text has five lines, the third line already reach the bottom of the div, i would like to hide the fourth and fifth lines till user click a button, which will change the div height to "auto" to display all the text, is there any way to do that? I am using primefaces.

Thanks.
12 years ago
JSF

You can try the java.io.RandomAccessFile class, which can be used to seek to the point that you want, without having to read everything all over again.



Thank you Henry. I did think about using the RandomAccessFile before, i will try that.

Currently, I open the file and read and close it every few seconds, I am wondering if I should open the file, then have a loop checking for new data coming in without close it. I am not sure which way is better?

Thanks.
12 years ago
Thank you William and Anayonkar.

Exactly how are you positioning at the end line of previous reading?

That is not something possible with BufferedReader which would have to read the whole file, resulting in what you observe.



Since I used bufferedReader to read line by line, I have counter to remember the line number.

Also note that a Reader is going to be doing character by character conversion to UNICODE, an expensive operation.



Thank you. I did not know it, but I was wondering maybe it will be more efficient if I use stream. The reason i use bufferedReader is that it help to maitain the line by line format, when a line is read and it has keyword inside, it will be recorded with "\n" to the file, later it will be displayed on a browser and may need to send to email as well. so i do not know if i use stream, it will still easy to have this line format maintained.

Instead of just opening a file after a time interval, I would suggest something like checking last modified time. If file is not modified at all, there's no point in opening the file in first place.



Good point, i will add that.

I'm not sure which OS you are working with, but in Linux, this can simply be done by grep command. No need to even open a file using Java classes. On Windows, there might be something similar to it.



It is windows, it will be wonderful if it has such feature, but I am wondering if there is any.

Thanks again for the help!

Regards,
12 years ago
Hi,

I am doing a project for monitoring the log files. When application(tomcat) start, it start one thread for one monitored file. The thread will run once very few seconds(pause by sleeping). Each time it will open and read the log file(bufferedReader) from the end line of previous reading. if any pre-defined keyword found in the log file, the matched line will be stored to stringbuilder, once it finish reading or the stringbuilder is bigger than a size, it will open particular file and write mathced content to the file.

The issue is that the (daily) log file will grow to be big (hundred Megebyte) from morning to the evening, and I noticed the cpu is 100% running when the file is big. I am wondering if there is good way to do this task like Bare Tail does which do not have much affect on memory and cpu?

Thanks.
12 years ago
Thank you Bear.

Yeah, document.getElementById(linkID) point to the right element, and I just tried


Which works, without the resetting the attribute innerHTML, both does not work. I do not know why.

I am not very sure if setting the className to that element will replace the old one, now I am sure after your informing .

Thanks.
oh, i forgot to to include that in the post, it is similar to the others except it has different background image.



Thank you.
Hi,

I have a few links on a web page, each of link has a background image, i want to change the background image when the link is clicked , related code as below:


First, I tried to use javascript to change the link class(method 2), then I tried to change the link background image directly(method 1), I also tried to define the link active through css, all of them does not perform the task I need. Please help to figure out the problem.

Thanks.
Hi,

I have a jsp page which user can select file(s) and select submit, then the servlet get the file(log) name and start reading the file in realtime(do something like send email if log file contains error). Then user can select another file to read and so on. This can be done. The problem is that later (e.g. two days later) if user choose to stop reading one of the log that is being read, what is the method/way to do that?

Thanks,

David
13 years ago
Oh, really, then i will try it.

Thank you for the help.
13 years ago
Hi,

I remember there is security restriction to prevent web application from reading file that are located in same machine but not same web app folder, is that true?

Now I have a need to read real time log files from different folders of the tomcat/apache, could that be fulfilled? If can, is that just like normal java read file or there is some special way to do that?

What I want to do is kind of like clicking a button on a jsp file, it will go to some specific log folders (same machine) and read real time log files one by one, find the special things in the log and do other things, like run a exe file which contains dos command.

I know this can be done easily without using jsp/servlet, but i want to include this one to a existing web application.


Thanks,
13 years ago