Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

tuntony wei

Greenhorn
+ Follow
since Jun 29, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by tuntony wei

Hi, guys:

I got a problem when I tried running my project. I use Flex, blazeds and java, and at the backgroud, my java code has to do some long time work. After I use a Remote Object to invoke this long time java process, the channel failed. Could anybody suggest me how I can hold this channel?

Here is the exception:
faultCode:Channel.Call.Failed faultString:'error' faultDetail:'NetConnection.Call.Failed: HTTP: Failed'

In the JSP, I can keep refresh current page and wait for the result. But in my flex GUI, the remote java code is called from a panel, in this situation, if I refresh the page, the panel will be gone. Is there any good idea to monitor remote object's status. for example, in Flex, I check the objec every 2 seconds, if job finished, I go to the ResultEvent listener? What API should I use for this

Or is there any other good way?

Thank you so so much
Tun
10 years ago

Bear Bibeault wrote:

tuntony wei wrote:Could you please suggest me where/how to configure it?


You can't. Period. As I said, it is not even a concept in web apps, so stop even thinking about it.

For the context param, do you mean the parameters of Tomcat?


Context parameters are set in the deployment descriptor. They have nothing to do with Tomcat.

It'd be best to have a properties file in which you can set such values that you do not want to hard-code into the code.



OK, thank you. I will try
10 years ago

Bear Bibeault wrote:There is no concept of a "current directory" in web applications.

I'd supply the location of a temp folder, outside of the web app, via a property or context param.



I call it current directory because of the "new java.io.File( "." ).getCanonicalPath()", sorry if the name is not good. Could you please suggest me where/how to configure it? For the context param, do you mean the parameters of Tomcat? I tried to make some configuration changes for tomcat, but I did not find anything good. Could you please tell me a little more?

Thank you very much
10 years ago

rk sharma wrote:You said very clearly, ok.but is your application running properly?



Yes, the application is runing properly. I can get the result I want. But I just do not like the way of puting my files under the CATALINA_HOME\bin, I hope I could put them somewhere else
10 years ago
Hi, guys
I am using eclipse and Tomcat to develope a simple Web tool. I have a question on the "new java.io.File( "." ).getCanonicalPath()" in my servlet/jsp. When I run the web project in my eclipse, I found the new java.io.File( "." ).getCanonicalPath() is D:\eclipse, But after I export the web project and put it into my CATALINA_HOME\webapp, the java.io.File( "." ).getCanonicalPath() is changed to CATALINA_HOME\bin

Here is what I am doing. In my servlet, I create a thread to carry a long time job. The thread is trying to read/write a batch of files, (these files includes some input files, some xml etc), do some db operations and put the result data into some files. These files have to be put at the current directory.

I found this current directory is the CATALINA_HOME\bin after I deployed my project in the CATALINA_HOME\webapp. I hope I could have a central place to put this batch of files and my result.

Could anybody give me a help and tell me how I can customize this dirrectory?

Thank you very much
10 years ago

steve souza wrote:Being as your start and stop times are local variables in TargetPerformance your code is thread safe. Why would you be surprised that 100 simultaneous users would be slower than 1 sequential one. I would expect that. You should get an idea about this being correct simply by timing with a wall clock the total time of your tests and dividing by 100 to get average time.

Having said that I would use JAMon (or other tool of your choice) to do the monitoring. It is much more flexible. It can easily monitor your business methods (MonitorFactory.start("doKPI001()") and do a lot more than that such as monitor your jdbc, page hits, ejb calls without changing your code at all. And for this reason it allows you to monitor in production as well as dev which is where your problems are likely to occur.

In fact I just made a release today that also lets your monitor your unix/linux scripts with jamon by calling the unix scripts I provide such as jstart.sh/jstop.sh and jadd.sh (adds an arbitrary value).

Steve - www.jamonapi.com



OK, great, now I am talking with our developers about my finding. And good to know the JAMon, we do need some good tool to monitor our KPI. I will try it. Thank you so much again
10 years ago

Himanshu Gupta wrote:

if I run 100 user request through Jmeter 1 by 1, then my average response time is 2+ seconds, but if I run 100 concurrent user through Jmeter, then my average response time was around 4 seconds. This makes me worried and confused



When you run one by run do you send the other request just after the first one or you wait to get the results of the previous request?

When you are running 100 concurrent threads you are increasing the load on the server. The request flood comes and server starts handling them. When it is one by one the server gets more time to process the 100 request.



When I run it one by one, I run it through JMeter. Basically, Jmeter send the 1st requst to HTML and then wait for a HTTP code such as 200. And then, Jmeter will send the 2nd and so on... With this method, my response time was around 2 seconds

With concurrent threads, the response time I got was around 4 seconds. But my understanding is that under the concurrent test, the response time should be close to the 2 seconds. That's why I worried about if statime/endtime were messed up when multiple threads comming. Do you think my code, or my test method, is OK? Do you mean the longer response time supposes to happen when dealing with the multple threads?

Thank you so much
10 years ago
Hi, guys:
I met a problem when I use multple threads to calculate the avaerage reponse time. My problem is I can not get the stable result, I put my code here and could anybody give me some suggestion.

1. My goal is to test the performance of a compnenet in our product. This is a J2ee product. Based on design, it is able to handle concurrent user's request.
2. my idea is to make a simple HTML, a link on the HTML can invoke one performance test case. In the test case, I record start time before the component starting to do the business logic, then I record the end time as soon as the component finished the job. So my response time = end - start. Finally I put it into a result.csv file.
3. I use JMeter to generate 100 concurrent user request to the HTML

Here is my code:

1. HTML:
<a href="TestServlet?command=KPI001" target="_self">KPI001</a>

2. TestServlet.java

3. TargetPerformance.java


My result:
if I run 100 user request through Jmeter 1 by 1, then my average response time is 2+ seconds, but if I run 100 concurrent user through Jmeter, then my average response time was around 4 seconds. This makes me worried and confused

Question:
1. Dirrectly feeling, should I worry about the start tiem and end time? When mutiple users come into the startTest method, is there any risk for them to be re-written?
2. In my code, I did not use any synchronized method/block because I think I do not need to. My understanding is that when concurrent users make requests, the TestServlet always did "TargetPerformance perf = new TargetPerformance ()", and then when the users did the "perf.startTest()", different user alwasy has its own copy of start time, end time and test result.
3. This is what I think. I think it should be this way but this part is also the part I worried most
Am I right? Could anybody give me some suggestion?
Thank you so so so much
10 years ago
Hi, guys
Thank you very much. I do not have any instance variables in my servlet and these 2 days, I tried to reproduce the problem so that I can narrow down the problem and post relevant code here. But it is really difficult to reproduce it and seems it only happens when there are many users. As my boss suggested, if not occurs freqently, we can ignore. Not a good boss, right?
10 years ago
JSP
Hi,
Thank you so much. The database function is from other part of my team. Unfortunitely, I can not change it. Now, I just changed my code to throw a thread. The thread is a worker to invoke the db func. Then at same time, my servlet/jsp is keeping refresh to monitor if the thread finished.

I saw lots of people doing in this way. So ... But I still feel confused because lots of people on web says "do not thrown thread in servlet", but this seems the only way to solve long time process. And servlet 3.0 supports asynchrozed task.... I am new to Servle/Jsp. There are really lots of things for me to learn.

Still, thank you so much for the advice. In future, I will do check the db func to make faster.


Jeff Ishar wrote:Hi tuntony,
If your database query takes more than 15 seconds then you need to check your method seriously where db interactions is happening i.e. doWork. Make sure you close the connections, catch exceptions and close the result set and other stuff (If using JDBC). Please post that method here.
In my web application even the biggest operation takes about 10 seconds, 15+ sec is far too much.

Cheers

10 years ago
Hi, everybody:
I am new to jsp/servlet and feel confused about the javabean used among JSPs and Servlets. I have a web app, I do following things:

1. StatusBean statusBean = new StatusBean(); // this is a local variable
2. statusBean.setXXX
...
3. statusBean.setXX
...
4. session.setAttribute("statusBean", statusBean);

And then, I will pass this session to few JSPs and servlets, and some fields in the statusBean might be changed in the following jsp/servlet, and finally, I finished some works and get result from this statusBean.

To me, when different clients visit the servlet, they got different sessions. So because of different sessions to different clients, the web container guarantees the statusBean is always different to different client. Am I right on this? If this is ture, I do not need worry too much. However, when I test my app, in some situation, client A's session shows client B's statusBean data. (I found this problem but it is not reproduced on every test) So, what should I do to gurantee client A always doing his job with his own statusBean, and client B doing with his too?

Thank you very much.
10 years ago
JSP
Hi, guys:

Thank you very much for suggestions. It seems starting a thread from servlet is the only way to do this.

Here I have a following question. I started a new thread from my servlet and the servlet redirected to a jsp, the new thread finished its job, Now I want the jsp can display the result obtained from the thread. So, before my servlet redirect to the JSP, I put the thread's reference into session, and then I refresh the jsp automatically again and again. But I just found I can not get the result is still null after the thread finished.

Can I do this? How can I keep refesh a jsp to watch a session or a javabean?

Thank you again
10 years ago
Hi, guys:

I just start to use Servlet and now I met a problem when I tried to call a method in my servlet. Could anybody give me some suggestions to solve this problem?

Here is what I am doing:

1. I have a form, <form name="inputform" action="PerformWebTestServlet" onsubmit="loadingPage()" method="post">
2. In the doPost(reqs, reps) method of the PerformWebActionServlet, I new another class and try to invoke a method of this class to get some result. Please see:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession(true);
DataBean dataBean = (DataBean) session.getAttribute("dataBean");
... ...
SingleTestWebImpl runner= new SingleTestWebImpl();

try {
runner.doWork(dataBean .getMppigName, dataBean.getVerifyxmlName, dataBean.getTestcasename(), "false", dataBean.getLogfile());

} catch (InvalidMappingException e) { }

RequestDispatcher requestDispatcher = request.getRequestDispatcher("SemanticTestResult.jsp");
requestDispatcher.forward(request, response);
}

3. My problem is the runner.doWork(). This method involves some database querying work. if it can be finished in a short time, everything is fine. It can go to the SemanticTestResult.jsp and shows the result. However, if the runner.doWork() needs a little longer time, for example 15+ seconds. The IE will show "This program cannot display the webpage" Please see the attached pic. And also I found the method runner.doWork() is sitll able to successfully finished in the console and at this time, if you input the right url of SemanticTestResult.jsp at IE, I am still able to see the right result.

I feel this is probably a connection timeout problem. But I just do not know how to solve this problem. I mean when the servlet runs the longer runner.doWork(), how can I let IE connection alway alive and wait for result?

Thank you so much.
10 years ago