Jsp for monitoring heapsize

I saw an article on the iPlanet Knowledge Base that says you can use a
jsp to monitor the heap size of the application server, but it doesn't
give the code for doing this. Does anyone have the code that you need
to put into the JSP in order to pull the heapsize and display it?
Thanks in advance,
Bryan

Figured it out. It was very simple. Here is the code that I used to
perform the task in case anyone else is interested.
<html>
<head>
<title>Memory Monitor JSP</title>
</head>
<body>
<%
double freeMem = Runtime.getRuntime().freeMemory();
double totalMem = Runtime.getRuntime().totalMemory();
double usedMem = totlMem-freeMem;
freeMem = freeMem/1000000;
totalMem = totalMem/1000000;
usedMem = usedMem/1000000;
%>
<center>
<b>Total Memory is <%=totlMem%> MB</b>
<br>
<br>
<b>Free Memory is <%=freeMem%> MB</b>
<br>
<br>
<b>Used Memory is <%=usedMem%> MB</b>
</center>
</body>
</html>
Thanks,
Bryan
Bryan Field wrote:
I saw an article on the iPlanet Knowledge Base that says you can use a
jsp to monitor the heap size of the application server, but it doesn't
give the code for doing this. Does anyone have the code that you need
to put into the JSP in order to pull the heapsize and display it?
Thanks in advance,
Bryan

Similar Messages

  • MacPro: How to prevent scanning for monitor after sleep?

    Hi everybody,
    So here's the deal: When I power up my MacPro or wake it up from sleep, it seems to do a quick search for connected displays and activates only the DVI output(s) which have a monitor connected to them. While I understand that behavior at boot time, I find it really troublesome when waking the MacPro from sleep.
    Here's why:
    I rarely turn off the MacPro completely, I much rather put it to sleep when I'm away. What I do, however, is to turn off the huge 30'' display that drains a lot of power when left on. When I come back, I just have to turn the display on before turning on the MacPro and everything is fine.
    However, there's one scenario where I systematically get caught and that's really... really annoying! It happens in combination with the EyeTV Software. When I'm away by the time a scheduled show starts, the EyeTV wakes up the MacPro and starts recording. That's exactly what it's supposed to do. However, since the monitor is turned off by the time the MacPro wakes up, it won't recognize it and the graphics card won't send any signal! So when I come back to the computer and turn on the screen, It says "No Signal". The solution at this point is putting the MacPro to sleep briefly and resume it with the display turned on this time. However, putting the Mac to sleep while EyeTV is recording a show causes the recording to be rendered useless.
    Is there a way to prevent the MacPro from rescanning for monitors after sleep? Or maybe there's a key combination to let it rescan manually?
    As far as I remember, it didn't do the rescan-monitors-after-sleep thing under Tiger, but not sure about that...
    Any help would be highly appreciated!
    MasOS X: 10.5.2 Leopard
    Mac Hardware: MacPro Dual-Core Intel Xeon 3GHz (from mid-2007)
    Graphics card: NVIDIA GeForce 7300 GT
    Monitor: Dell 3008WFP
    Greetings,
    Mike

    What I do, however, is to turn off the huge 30'' display that drains a lot of power when left on.
    The display should go to "Active-off mode" (amber power light) when the computer sleeps. This uses less than 2 watts.
    <http://support.dell.com/support/edocs/monitors/3008WFP/en/ug/about.htm#Product% 20Features>
    If you do want the monitor off (e.g. to save power while EyeTV is recording), you could use a DVI Detective
    <http://www.gefen.com/kvm/product.jsp?prod_id=4714>

  • Thread waiting for monitor - appending to previous post

    04:25:51,721 ERROR [ExecuteThread: '55' for queue: 'weblogic.kernel.Default'] com.documentum.web.common.Trace - SessionSynch@bc53ac[lockCount=2,lockOwner=Thread[ExecuteThread: '54' for queue: 'weblogic.kernel.Default',5,Thread Group for Queue: 'weblogic.kernel.Default']]: Timed out waiting in lock()
    java.lang.IllegalStateException: SessionSynch@bc53ac[lockCount=2,lockOwner=Thread[ExecuteThread: '54' for queue: 'weblogic.kernel.Default',5,Thread Group for Queue: 'weblogic.kernel.Default']]: Timed out waiting in lock()
    at com.documentum.web.common.SessionSync.lock0(SessionSync.java:181)
    at com.documentum.web.common.SessionSync.lock(SessionSync.java:68)
    at com.documentum.web.form.FormProcessor.lockSession(FormProcessor.java:2026)
    at com.documentum.web.form.FormProcessor.invokeMethod(FormProcessor.java:1614)
    at com.documentum.web.form.FormProcessor.fireOnExitEvent(FormProcessor.java:1463)
    at com.documentum.web.form.FormProcessor.fireOnExitEvent(FormProcessor.java:1459)
    at com.documentum.web.form.FormProcessor.fireOnExitEvent(FormProcessor.java:1438)
    at com.documentum.web.form.JumpOperation.execute(JumpOperation.java:80)
    at com.documentum.web.form.FormProcessor.openForm(FormProcessor.java:219)
    at com.documentum.web.form.WebformTag.doStartTag(WebformTag.java:127)
    at jsp_servlet._wdk.__historyreleased._jsp__tag0(__historyreleased.java:164)
    at jsp_servlet._wdk.__historyreleased._jspService(__historyreleased.java:125)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
    at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:525)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:454)
    at com.documentum.web.form.FormProcessor.dispatchURL(FormProcessor.java:2194)
    at com.documentum.web.form.FormProcessor.doFreshInclude(FormProcessor.java:1082)
    at com.documentum.web.form.FormProcessor.doFreshInclude(FormProcessor.java:1058)
    at com.documentum.web.form.FormProcessor.redirect(FormProcessor.java:1010)
    at com.documentum.web.form.FormProcessor.openForm(FormProcessor.java:257)
    at com.documentum.web.form.WebformTag.doStartTag(WebformTag.java:127)
    at jsp_servlet._webcomponent._library._locator.__locatorcontainer._jsp__tag2(__locatorcontainer.java:704)
    at jsp_servlet._webcomponent._library._locator.__locatorcontainer._jsp__tag1(__locatorcontainer.java:671)
    at jsp_servlet._webcomponent._library._locator.__locatorcontainer._jspService(__locatorcontainer.java:154)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.documentum.web.servlet.ResponseHeaderControlFilter.doFilter(ResponseHeaderControlFilter.java:317)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.documentum.web.servlet.CompressionFilter.doFilter(CompressionFilter.java:84)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at com.documentum.web.env.WDKController.processRequest(WDKController.java:95)
    at com.documentum.web.env.WDKController.doFilter(WDKController.java:83)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3393)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2140)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2046)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)
    at weblogic.work.ExecuteRequestAdapter.execute(ExecuteRequestAdapter.java:21)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)

    Yes Jay, You are right. I have taken thread dump 10 samples and i could see that Thread State is not moving... I have increased the StuckThread Timeout to 800 from 600
    Thread dump 1/10 "ExecuteThread: '32' for queue: 'weblogic.kernel.Default'" daemon prio=3 tid=0x01b28350 nid=0xa9 waiting for monitor entry [0x71e3e000..0x71e3fc70]      at com.documentum.wp.app.WpRoleService.getRoleModel(WpRoleService.java:174)      - waiting to lock <0x9c986ed0> (a java.lang.Object)      at com.documentum.wp.app.WpRoleService.getUserRole(WpRoleService.java:92)      at com.documentum.wp.session.LoginUtil.validateUserDomain(LoginUtil.java:58)      at com.documentum.wp.session.WpAuthenticationService.login(WpAuthenticationService.java:70)      at com.documentum.web.formext.session.Login.authenticate(Login.java:1041)      at com.documentum.web.formext.session.Login.onLogin(Login.java:359)      at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)      at java.lang.reflect.Method.invoke(Method.java:585)      at com.documentum.web.form.FormProcessor.invokeMethod(FormProcessor.java:1633)      at com.documentum.web.form.FormProcessor.invokeMethod(FormProcessor.java:1487)      at com.documentum.web.form.FormProcessor.fireActionEvent(FormProcessor.java:1303)      at com.documentum.web.form.RecallOperation.execute(RecallOperation.java:101)      at com.documentum.web.form.FormProcessor.processAction(FormProcessor.java:113)      at com.documentum.web.form.FormAction.processAction(FormAction.java:107)      at com.documentum.web.env.WDKController.doStartRequest(WDKController.java:191)      at com.documentum.web.env.WDKController.processRequest(WDKController.java:92)      at com.documentum.web.env.WDKController.doFilter(WDKController.java:83)      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3393)      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)      at weblogic.security.service.SecurityManager.runAs(Unknown Source)      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2140)      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2046)      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)      at weblogic.work.ExecuteRequestAdapter.execute(ExecuteRequestAdapter.java:21)      at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:145)      at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:117)

  • Waiting for Monitor Lock on java/util/zip/ZipFile@6C816668/6C816674

    Hi,
    My server is creating the Thread dumps. After analysing, I found the following logs. Can any thing tell me that why is it stuck? How can I resolve this problem?
    Thanks In Advance.
    at java/util/zip/ZipFile.getEntry(ZipFile.java:287(Compiled Code)) at weblogic/utils/classloaders/ZipClassFinder.getSource(ZipClassFinder.java:32(Compiled Code)) at weblogic/utils/classloaders/JarClassFinder.getSource(JarClassFinder.java:45(Compiled Code)) at weblogic/utils/classloaders/MultiClassFinder.getSource(MultiClassFinder.java:64(Compiled Code)) at weblogic/utils/classloaders/MultiClassFinder.getSource(MultiClassFinder.java:64(Compiled Code)) at weblogic/utils/classloaders/MultiClassFinder.getSource(MultiClassFinder.java:64(Compiled Code)) at weblogic/utils/classloaders/MultiClassFinder.getSource(MultiClassFinder.java:64(Compiled Code)) at weblogic/utils/classloaders/MultiClassFinder.getSource(MultiClassFinder.java:64(Compiled Code)) at weblogic/utils/classloaders/CodeGenClassFinder.getSource(CodeGenClassFinder.java:33(Compiled Code)) at weblogic/utils/classloaders/GenericClassLoader.findResource(GenericClassLoader.java:209(Compiled Code)) at java/lang/ClassLoader.getResource(ClassLoader.java:422(Compiled Code)) at weblogic/utils/classloaders/GenericClassLoader.getResource(GenericClassLoader.java:169(Compiled Code)) at weblogic/utils/classloaders/ChangeAwareClassLoader.getResource(ChangeAwareClassLoader.java:112(Compiled Code)) at com/opensymphony/xwork2/util/ClassLoaderUtil.getResource(ClassLoaderUtil.java:83(Compiled Code)) at org/apache/struts2/views/freemarker/StrutsClassTemplateLoader.getURL(StrutsClassTemplateLoader.java:33(Compiled Code)) at freemarker/cache/URLTemplateLoader.findTemplateSource(URLTemplateLoader.java:75(Compiled Code)) at freemarker/cache/MultiTemplateLoader.findTemplateSource(MultiTemplateLoader.java:111(Compiled Code)) at freemarker/cache/TemplateCache.acquireTemplateSource(TemplateCache.java:600(Compiled Code)) at freemarker/cache/TemplateCache.findTemplateSource(TemplateCache.java:576(Compiled Code)) at freemarker/cache/TemplateCache.getTemplate(TemplateCache.java:293(Compiled Code)) at freemarker/cache/TemplateCache.getTemplate(TemplateCache.java:235(Compiled Code)) at freemarker/template/Configuration.getTemplate(Configuration.java:487(Compiled Code)) at freemarker/core/Environment.getTemplateForInclusion(Environment.java:1464(Compiled Code)) at freemarker/core/Include.accept(Include.java:157(Compiled Code)) at freemarker/core/Environment.visit(Environment.java:209(Compiled Code)) at freemarker/core/MixedContent.accept(MixedContent.java:92(Compiled Code)) at freemarker/core/Environment.visit(Environment.java:209(Compiled Code)) at freemarker/core/Environment.process(Environment.java:189(Compiled Code)) at freemarker/template/Template.process(Template.java:237(Compiled Code)) at org/apache/struts2/components/template/FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:148(Compiled Code)) at org/apache/struts2/components/UIBean.mergeTemplate(UIBean.java:530(Compiled Code)) at org/apache/struts2/components/UIBean.end(UIBean.java:484(Compiled Code)) at org/apache/struts2/views/jsp/ComponentTagSupport.doEndTag(ComponentTagSupport.java:43(Compiled Code)) at jsp_servlet/_web_45_inf/_decorators/__tpmsdecorator._jspService(__tpmsdecorator.java:475(Compiled Code)) at weblogic/servlet/jsp/JspBase.service(JspBase.java:34(Compiled Code)) at weblogic/servlet/internal/StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:223(Compiled Code)) at weblogic/servlet/internal/StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125(Compiled Code)) at weblogic/servlet/internal/ServletStubImpl.execute(ServletStubImpl.java:283(Compiled Code)) at weblogic/servlet/internal/ServletStubImpl.execute(ServletStubImpl.java:175(Compiled Code)) at weblogic/servlet/internal/RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:500(Compiled Code)) at weblogic/servlet/internal/RequestDispatcherImpl.include(RequestDispatcherImpl.java:431) at com/opensymphony/module/sitemesh/filter/PageFilter.writeDecorator(PageFilter.java:173) at com/opensymphony/module/sitemesh/filter/PageFilter.applyDecorator(PageFilter.java:158) at com/opensymphony/module/sitemesh/filter/PageFilter.doFilter(PageFilter.java:62) at weblogic/servlet/internal/FilterChainImpl.doFilter(FilterChainImpl.java:42(Compiled Code)) at org/acegisecurity/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265(Compiled Code)) at org/acegisecurity/intercept/web/FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107) at org/acegisecurity/intercept/web/FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72) at org/acegisecurity/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275(Compiled Code)) at org/acegisecurity/ui/ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110) at org/acegisecurity/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275(Compiled Code)) at org/acegisecurity/wrapper/SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81) at org/acegisecurity/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275(Compiled
    Regards,
    Developer.

    Hi,
    I've a follow-up question, I have the following thread in several thread dumps:
    "AJPRequestHandler-ApplicationServerThread-717" prio=1 tid=0x4046b988 nid=0x3dd3 waiting for monitor entry [3845e000..3845e86c]
         at java.net.Inet4Address.getAddress(Inet4Address.java:287)
         at com.evermind.server.http.StandardRequestLogger.appendIP(StandardRequestLogger.java:187)
         at com.evermind.server.http.StandardRequestLogger.log(StandardRequestLogger.java:45)
         - locked <0x663b2088> (a com.evermind.server.http.StandardRequestLogger)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:906)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    What is the monitor this thread is waiting for? According to the source in Inet4Address at line 287 the method tries to create a new byte array... is there some system monitor which can't be seen in the thread dump?
    This thread holds a lock (0x663b2088) 46 other threads are waiting for...
    Thanx in advance for any hints.
    Regards,
    Ingo

  • How to get values from a table(in jsp) for validation using javascript.

    hi,
    this is praveen,pls tell me the procedure to get values from a table(in jsp) for validation using javascript.
    thank you in advance.

    Yes i did try the same ..
    BEGIN
    select PROD_tYPE into :P185_OFF_CITY from
    magcrm_setup where atype = 'CITY' ;
    :p185_OFF_CITY := 'XXX';
    insert into mtest values ('inside foolter');
    END;
    When i checked the mtest table it shos me the row inserted...
    inside foolter .. Now this means everything did get execute properly
    But still the vallue of off_city is null or emtpy...
    i check the filed and still its empty..
    while mtest had those records..seems like some process is cleaining the values...but cant see such process...
    a bit confused..here..I tried on Load after footer...
    tried chaning the squence number of process ..but still it doesnt help
    some how the session variables gets changed...and it is changed to empty
    Edited by: pauljohny on Jan 3, 2012 2:01 AM
    Edited by: pauljohny on Jan 3, 2012 2:03 AM

  • Precompilation of JSPs for default web application

    Hello,
    Once in a while I need to redeploy my "Default" web application. I would like to have its all JSPs precompiled, so that it was immediatly available after redeployment.
    However, if I try to redeploy my web application (.war file) under, let's say, "DefaultWebApp" root context, using the administration console, with the "Precompile JSPs" option enabled, it does compile all JSPs, but ONLY those deployed under the "DefaultWebApp" root context.
    However, If I access a url like "http://somehost/SomeResource.jsp" (a file that belongs to that default web application"), I can see (due to a pause) that my JSPs have not been compiled under the root context.
    Is there any way to precompile JSPs for my default web applications?
    Sincerely,
    Sergei Batiuk.

    Hello,
    Once in a while I need to redeploy my "Default" web application. I would like to have its all JSPs precompiled, so that it was immediatly available after redeployment.
    However, if I try to redeploy my web application (.war file) under, let's say, "DefaultWebApp" root context, using the administration console, with the "Precompile JSPs" option enabled, it does compile all JSPs, but ONLY those deployed under the "DefaultWebApp" root context.
    However, If I access a url like "http://somehost/SomeResource.jsp" (a file that belongs to that default web application"), I can see (due to a pause) that my JSPs have not been compiled under the root context.
    Is there any way to precompile JSPs for my default web applications?
    Sincerely,
    Sergei Batiuk.

  • How to construct table in jsp for the resultset from helper class

    Hi Dudes!!!
    Want to construct table in jsp for the resultset, but the resultset are retrieved at the helper class.I constructed Table in Helper class Using StringBuffer and return it as string from the helper class.Is their any other feasible and efficient way to construct table in Jsp for the resultset from Helper class.Solution will be highly appreciated.Thanx in Advance.

    no, we can't.
    Certainly noone can with such vague specifications even if they had the intent to do so.
    "the computer", which computer?
    "attach to our current page", what is meant by that?
    And noone should ever help you if you're planning to breach security anywhere.

  • Is the Thunderbolt Port on Macbook Pro 15" 2011 onyl for monitor ?

    Hello community
    I have a MBP 15" from 2011, Is the Thunderbolt Port on on this only for monitor ?
    I'm considering to buy a TB extern HD for backup, want to be sure before I give my money away.
    Thanks in advance !
    P.

    Thunderbolt has got the ability to transfer audio, video and data, and it's only compatible with Thunderbolt devices and adapters. You can also connect monitors.
    Additionally, it's compatible with Mini DisplayPort, so if you have a Mini DisplayPort cable or adapter, you can use it, so you don't have to buy other adapters

  • From PHP to JSP for a search-responder.php

    I have been asked to use the "search-as-you-type" solution offered up by Google at [http://code.google.com/p/search-as-you-type/|http://code.google.com/p/search-as-you-type/]. The documentation offered by Google is pretty much straight forward but of course the actual piece of code that gets the data is built in PHP and my client needs this to be used on a page serving up JSP.
    I am learning JSP and moving from PHP and ASP and learning quickly but not quick enough to finish the project.
    Would anyone be able and willing to help me convert the functions in the following PHP code into JSP?
    Thanks in advance to anyone who takes the time to help me.
    <?php
    * Copyright (C) 2006 Google Inc.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *      http://www.apache.org/licenses/LICENSE-2.0
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    * Search-as-you-type sample Ajax responder
      // Adding a cache control so that browsers won't cache Ajax requests
      header("Cache-Control: no-cache");
      header("Content-Type: text/html; charset=UTF-8");
       * Get the sample data from the text file.
       * @return array Loaded data
      function GetData() {
        $data = array();
        $file = file("test-data.txt");
        foreach($file as $record) {
          $record = explode("|", trim($record));
          if (count($record) == 4) { // Ignore invalid lines
            $data[] = $record;
        return $data;
       * Get the results based on user's query.
       * @param string $query Query
       * @param array $data Sample data
       * @return array Result array
      function GetResults($query, $data) {
        $results = array();
        $queryLength = strlen($query);
        foreach ($data as $record) {
          if (substr(strtolower($record[0]), 0, $queryLength) == $query) {
            $result = array();
            $result['name'] = $record[0];
            $result['type'] = $record[1];
            $result['content'] = $record[2];
            $result['moreDetailsUrl'] = $record[3];
            $result['style'] =
              ($query == strtolower($record[0])) ? 'expanded' : 'normal';
            $results[] = $result;
        return $results;
      // Get the data and the query
      $data = GetData();
      $query = strtolower(ltrim($_GET['query']));
      // Build response
      $response = array();
      $response['query'] = $query;
      $response['results'] = GetResults($query, $data);
      if (count($response['results']) == 1) {
        $response['autocompletedQuery'] = $response['results'][0]['name'];
      // Output response
      echo "searchAsYouType.handleAjaxResponse(";
      echo json_encode($response);
      echo ");";
    ?>

    Thanks for your comment Gimbal2.
    I have already been thoroughly surprised at how different JSP is from PHP. I am finding quite hard to wrap my head around the whole process to be honest.
    I am beginning to see that JSP and PHP work in a totally different way than each other.
    I am not technically trying to translate or convert the PHP file as much as I am trying to build a file in JSP that does the same functions. The main functions of the PHP script are commented by Google and should be easily enough re-written in JSP in order to produce similar results.
    Since the output needs to be in a JSON format when passed to the .js file you'd think this would be better suited as a .jsp file as well or even a JAVA Applet, Servlet or even a bean. Since the whole site is already built in JSP for a multitude of other functions it seems likely that adding on more to read data from a source file and send it back to the .JS would be straight forward, but I could be wrong. But again I am not familiar enough with JAVA or JSP (yet) to make heads or tails of this.
    1. // Adding a cache control so that browsers won't cache Ajax requests
    2. * Get the sample data from the text file. @return array Loaded data
    3. * Get the results based on user's query.
    * @param string $query Query
    * @param array $data Sample data
    * @return array Result array
    4. // Get the data and the query
    5. // Build response
    6. // Output response

  • Alert Repeat Count For Monitor

    When I look in the Active Alerts view in the console many of the alerts have a repeat count. I understand if they are created from a rule and have alert suppression turned on this means only one alert was created instead of having multiple alerts that
    are exactly the same open. But for monitors what does this repeat count refer to? I checked the state changes in health explorer and they seem to be somewhere along with that number. When I run an alert report it shows repeat count also but that seems to mean
    how many alerts were actually created over the period of time the report is ran for. Please help since I'm not sure what the repeat count is referring to for monitors (not rules) that created alerts which are currently open.

    1) But for monitors what does this repeat count refer to?
    Repeat count is meaningless for monitor because is always zero.
    2) When I run an alert report it shows repeat count also but that seems to mean how many alerts were actually created over the period of time the report is ran for.
    This repeat count value in reporting is different to repeat count value in alert view.
    In Reporting, the repeat count is how many alerts were actually created over the period of time and is a calculated field which sum up alerts over certain period of time.
    In Alert View, the repeat count is the field value of alert record
    Roger

  • Jstack shows a thread waiting for monitor entry but it's already acquired

    I have a heavy load website powered by tomcat-6.0.14 and jdk1.6.0_02-b05(amd64) on a 2 dual-core amd Opteron. When tomcat started, and I directed the http request(~200/s) abruptly to tomcat, it looks choked for over one minute, and if I took off the http requests, tomcat can recover in a few minutes.
    Then I use jstack during the choke time to find what's the cause, where I found a strange situation. Almost all threads are blocking on getting a log4j lock(I think it's normal,since log4j use a coarse lock), but one thread which already got the lock are also blocked. Below is the stack trace.
    "http-172.23.24.29-8011-exec-175" daemon prio=10 tid=0x00002aad37843400 nid=0x542d waiting for monitor entry [0x0000000052e55000..0x0000000052e55da0]
    java.lang.Thread.State: BLOCKED (on object monitor)
    at org.apache.log4j.Category.callAppenders(Category.java:201)
    - locked <0x00002aaab39d5670> (a org.apache.log4j.spi.RootLogger)
    at org.apache.log4j.Category.forcedLog(Category.java:388)
    at org.apache.log4j.Category.log(Category.java:853)
    at org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:133)
    at com.xxx.xxxx.TimingLogFilter.doFilter(TimingLogFilter.java:39)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:887)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:696)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2009)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    And all the other threads waiting for the log4j lock.
    "http-172.23.24.29-8011-exec-176" daemon prio=10 tid=0x00002aad37773800 nid=0x542e waiting for monitor entry [0x0000000052f56000..0x0000000052f56b20]
    java.lang.Thread.State: BLOCKED (on object monitor)
    at org.apache.log4j.Category.callAppenders(Category.java:201)
    - waiting to lock <0x00002aaab39d5670> (a org.apache.log4j.spi.RootLogger)
    at org.apache.log4j.Category.forcedLog(Category.java:388)
    at org.apache.log4j.Category.log(Category.java:853)
    at org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:133)
    at com.xxx.xxxxx.TimingLogFilter.doFilter(TimingLogFilter.java:39)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:887)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:696)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2009)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    I'm really wondering why jstack shows the first thread is BLOCKED but no blocker.
    And also, it's not a deadlock, since I made jstack log after sever seconds, and found this time another thread has the same problem.
    "http-172.23.24.29-8011-exec-170" daemon prio=10 tid=0x00002aad3784d800 nid=0x5428 waiting for monitor entry [0x0000000052950000..0x0000000052950c20]
    java.lang.Thread.State: BLOCKED (on object monitor)
    at org.apache.log4j.Category.callAppenders(Category.java:201)
    - locked <0x00002aaab39d5670> (a org.apache.log4j.spi.RootLogger)
    at org.apache.log4j.Category.forcedLog(Category.java:388)
    at org.apache.log4j.Category.log(Category.java:853)
    at org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:133)
    at com.xxx.xxxx.TimingLogFilter.doFilter(TimingLogFilter.java:35)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:887)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:696)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2009)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    What's the cause? Is jstack accurate? Or, the problem is caused by hotspot compling since tomcat is just started? Or it's just because log4j's coarse lock? ( but after the starup, tomcat can handle the same traffic without any problem, and jstack shows no log4j block at all.)
    Thanks in advance.
    Jimcgnu

    "http-172.23.24.29-8011-exec-175" daemon prio=10 tid=0x00002aad37843400 nid=0x542d waiting for monitor entry [0x0000000052e55000..0x0000000052e55da0]
    java.lang.Thread.State: BLOCKED (on object monitor)
    at org.apache.log4j.Category.callAppenders(Category.java:201)
    - locked <0x00002aaab39d5670> (a org.apache.log4j.spi.RootLogger)
    It seems like a Dead Lock.
    The thread must have entered into a synchronized block/method1() and acquired a lock.
    - locked <0x00002aaab39d5670> (a org.apache.log4j.spi.RootLogger)
    While having lock the thread might be trying to acquire a lock to another synchronized block/method2()
    waiting for monitor entry
    java.lang.Thread.State: BLOCKED (on object monitor)
    and someother thread might have already acquired a lock to that block/method2().
    Can we check for Dead Lock??

  • How to select the right JSP for a locale

    This may be a very stupid question but someone please help me out. I've
    looked at the JSP spec and the Weblogic documentation and even browsed the
    newsgroup and I still can't figure this out. Perhaps I'm just being dense
    (more than likely).
    What we want to do is support multiple locals from one server. My idea is
    that we'd write the JSP in English then hire translation companies to
    convert the JSP to French,German, Japanese, etc.(We've moved all the java
    code out of the JSPs using taglibs/java beans to make this easier). What
    we'd like to do is have all the languages on the server at once and based on
    the local of the client select the right JSP. We'd still like the URL to
    remain constant. What I can't seem to figure out is how to have one URL
    (like http:/www.myserver.com/example.JSP) and have the server select the
    right real JSP for the local (like example-en.JSP, example-fr.JSP, etc).
    I had hoped I could find a deployment descriptor (J2EE or Weblogic specific)
    directive that mapped a URL to a set of JSP based on locale but I don't see
    one.
    How does one make this happen or is the wrong way to do it". If it the
    "wrong way" what is the right way? Any links or example someone can point
    me to would be great.
    Kent

    We use a Servlet "filter" (not the Servlet 2.3 sense, but a 2.2 servlet that
    does a RequestDispatch.forward())
    This filter selects the most appropriate JSP page (using a similar naming
    convention to the one you indicate), then server-side forwards to it. Works
    quite well.
    j
    "Kent Mitchell" <[email protected]> wrote in message
    news:[email protected]...
    So has anybody come up with other solutions that work better. I was
    thinking about having a "main" jsp that all it did was check the local and
    then forward the request to the right internationalized jsp. So forexample
    I'd have the three files:
    someMain.jsp
    someMain-EN.jsp
    someMain-FR.jsp
    The main check the local and forwards to EN for English and FRfor French.
    etc.. Has anyone done anything like this? Is so what were the pros and
    cons?
    Kent
    "Mettu Kumar" <[email protected]> wrote in message
    news:[email protected]...
    Completely Agree. Once you start using TAG's get Internationalized
    Strings
    tools
    are less useful.
    Kumar.
    Kent Mitchell wrote:
    O.K. but doesn't this sort of make JSP editing tools like dreamweaver
    pretty
    much useless because of all the embedded Java code or and I missing
    something.
    "Mettu Kumar" <[email protected]> wrote in message
    news:[email protected]...
    Kent,
    Most common way of doing this is having one jsp where All the
    Textual
    messages in the page are read from properties file based on Locale.
    Kumar.
    Kent Mitchell wrote:
    This may be a very stupid question but someone please help me out.
    I've
    looked at the JSP spec and the Weblogic documentation and evenbrowsed
    the
    newsgroup and I still can't figure this out. Perhaps I'm just
    being
    dense
    (more than likely).
    What we want to do is support multiple locals from one server. My
    idea
    is
    that we'd write the JSP in English then hire translation companies
    to
    convert the JSP to French,German, Japanese, etc.(We've moved all
    the
    java
    code out of the JSPs using taglibs/java beans to make this
    easier).
    What
    we'd like to do is have all the languages on the server at once
    and
    based on
    the local of the client select the right JSP. We'd still like the
    URL
    to
    remain constant. What I can't seem to figure out is how to have
    one
    URL
    (like http:/www.myserver.com/example.JSP) and have the server
    select
    the
    right real JSP for the local (like example-en.JSP, example-fr.JSP,etc).
    I had hoped I could find a deployment descriptor (J2EE or Weblogicspecific)
    directive that mapped a URL to a set of JSP based on locale but I
    don't
    see
    one.
    How does one make this happen or is the wrong way to do it". If
    it
    the
    "wrong way" what is the right way? Any links or example someone
    can
    point
    me to would be great.
    Kent

  • How can I use 1 JSP for edit/create functionality?

    Hi All,
    Does anybody have an example of using one JSP for both editing and creating an object? I am pretty sure I can handle most of it, but am not sure about how I can specify different messages from the resource bundle (i.e. modifying the screen title for the different uses, "New Campaign" vs. "Edit Campaign").
    My background is in PHP and DHTML (i.e. more front-end) and I'm just starting with Java and JSF. As such, I want to be sure that I'm using appropriate patterns for my programming.
    Thank you in advance for any help,
    Matt

    I make the difference between modifying an existing object and a new one by the ID in the object. Each object has a unique ID in my app assigned by the database. So if the ID is 0, the user is creating a new object, not stored in the DB yet. I store the object to be edited/modified in the session before displaying the page:
    For the title:
    <h:outputText value="Edit Material" rendered="#{sessionScope.selectedMaterial.materialId != 0}"/>
    <h:outputText value="New Material" rendered="#{sessionScope.selectedMaterial.materialId == 0}"/>For the action buttons:
    <h:commandButton value="Update Material" action="#{MaterialControllerBean.updateMaterial}" rendered="#{sessionScope.selectedMaterial.materialId != 0}"/>
    <h:commandButton value="Create Material" action="#{MaterialControllerBean.createMaterial}" rendered="#{sessionScope.selectedMaterial.materialId == 0}"/>

  • How to use taglibs in JSP for Database access

    Hi
    Could any one please tell me how to use taglibs in JSP for Database access
    with regrds
    Jojo

    This is a sample how to connect to a MySQL database with JSTL 1.0:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>JSTL MySQL</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <c:catch var="e">
    <sql:setDataSource var="datasource" url="jdbc:mysql://Your_Server_Name_Here/You_Schema_Here"
                           user="Your_Username_Here" password="Your_Password_Here"
                           driver="com.mysql.jdbc.Driver"/>
    <c:out value="datasource= ${datasource},  Class = ${driver.class}"/>
    <br />
    <br />
    <sql:query var="deejays" dataSource="${datasource}">SELECT * FROM Your_Table_Name_Here</sql:query>
    <table>
    <%-- Get the column names for the header of the table --%>
    <c:forEach var="columnName" items="${deejays.columnNames}"><th><c:out value="${columnName}"/></th></c:forEach>
    <tbody>
    <%-- Get the value of each column while iterating over rows --%>
    <c:forEach var="row" items="${deejays.rows}">
      <tr><c:forEach var="column" items="${row}">
            <td><c:out value="${column.value}"/></td>
          </c:forEach>
      </tr>
    </c:forEach>
    </tbody>
    </table>
    </c:catch>
    <br />
    <br />
    <c:if test="${e!=null}"><span class="error">Error</span>�
      <c:out value="${e}" />
    </c:if>
    </body>
    </html>And this thread might help you:
    http://forum.java.sun.com/thread.jspa?threadID=639471&tstart=44

  • Why not use Jsp for  control in MVC2 ?

    hi
    i am rajendra , i am preparing interview FAQ, so please give me my Que. Ans.
    1) we are using servlet for control in MVC2 Module,then why we can not use
    Jsp for control in mvc2
    2) if we used jsp for control in mvc2 then what is disadvantage compare to if using servlet for control in mvc2
    Please give me ans. as soon as..
    Thanks.

    Are you preparing a FAQ for others or are you just cramming before an upcoming interview and someone gave you a set of questions? It looks more like the latter to me.
    If you haven't actually written any MVC based code, you won't be able to snow the interviewer. It's better to just relax, get a good night's sleep and impress them with your willingness to learn, your fit with the team and whatever real accomplishments you have to show.
    If you really want an answer to this I suggest that you try writing an MVC2 system using JSP for the controller, which is possible, and then try doing the same in a servlet, or better yet using a framework like Spring MVC or Struts to provide the servlet for you and let you concentrate on your application.

Maybe you are looking for

  • Brand new HP Officejet Pro 8000 Wireless Printer

    When turned on the light in the on/off switch continues to flash & the printer continuously cycles through its set-up mode.  If we try to print while this is going on we end up with illegible final material.

  • How do I edit notes on my Mac mini?

    I have just switched from a PC to a Mac, and for convenience I am still using Thunderbird for email. As far as I can tell from the User Guide, Notes on the iPhone can be edited in Mail. Is there a way to set up Mail without having it be my default em

  • Sql substitution

    Hi, I have a query like this: select company, productfamily, sum(fy_quota), sum(ytd_orders), max(order_perf) from view_order_test where lower(region) like lower(:P66_REGION || '%') group by company, productfamily now I need some help on how to substi

  • Can't install Final Cut Pro 5 on a New Macbook pro

    My macbook has a 2.8ghz processor and meets all of the required hardware and software but it says that it does not and will not install. I am new to Mac and do not know how to fix this or who to contact.

  • How to copy the queries that i have created for an ods to cube?

    Hi all, My queries are generated using ods. there are 20-30 queries generated on that ods.  And right now i have created a cube based on that ods. And i wanted to know is there any way that i can copy all the queries that have been created in the ods