How to use multithreads in servlet or beans?

I need a servlet to run every 2 minutes to refresh a application varible.How can I do this?Please show me code examples,Thanks!!

sounds to me the application should make periodic requests to the servlet, if so, use a thread in the app to request/sleep.

Similar Messages

  • How to use multithreading for asynchronous operation

    hi! i am really new to java, i want to improve the performance of my code, some suggested to implement asynchronous operation using multithreading. Please help me how to use multithreading for asynchronous operation. thanks in advance.

    http://java.sun.com/docs/books/tutorial/essential/threads/
    Note, however, that just making something multithreaded won't necessarily improve performance. You either need multiple CPUs or there needs to be some I/O going on that blocks while something else could be done--other I/O or computing.

  • How to use session variable in JSP function  & How to use both JSP  Servlet

    Hi,
    I am new to JSP and servlets
    Still I am devloping a website in JSP. I am not mixing JSP with servlets, but I do create Java files for bean, logic and database works.
    I try to keep the hard coding part out of JSP.
    I dont how to use both JSP and Servlets in combination.
    Hence If needed I write some functions in JSP.
    but it gives me error
    +<%! public void abc()+
    +{+
    int intUserId = Integer.valueOf((Integer) session.getAttribute("MySession_UserID"));
    +}+
    +%>+
    Saying cannot find symbol session
    1) So can u please tell how can I access session variables within JSP function
    2) And also give me some links/tutorials about useing both JSP and Servlets in combination.
    Thanks
    Venkat

    The application architecture when you use Servlets and JSP in a standard MVC pattern is explained here (under the heading "Integrating Servlets and JSP Pages") and here ...

  • How to use JNI with Servlets

    Hi
    i was trying to do some example with JNI. I can use JNI with standalone Java application but I just cannot figure out how I can use JNI with Servlet.
    Can some one show me a sample code using JNI with Servlets.
    thanks very much

    hi,
    I am also facing the same problem,
    when I am using JNI with stand alone application it works fine but when i tried to use it with a servlet It gives unsatisfied linker error
    stack: java.lang.UnsatisfiedLinkError: createSocket
         at RelayConnector.createSocket(Native Method)
         at RelayServlet.doGet(RelayServlet.java:70)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:891)
         at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:458)
    It seems i have to do some path settings in my iplenet web server.
    If some one have faced the problem i would be glad to know the solution for this, i am literally bugged up,....

  • How to use special aggregation in bi  beans

    Dear Gurus:
    I am using Bi beans in a project, on cube has a banlance measure, I set the last() aggregation in olap option with OEM, But when I query this cube, this measure still use default sum(), So whould you please help me how to use this special aggregation in bi beans.

    George,
    One way to get non-additive aggregations is to use an Analytic Workspace, or AW. AWs support all the aggregation operations, and can be exposed through the OLAP Catalog as "fully solved" cubes, in which case
    the OLAP API will merely fetch the correctly computed aggregate values.
    Today, setting up an AW for use by BI Beans and the OLAP API requires lengthy scripts that create the necessary ADTs and Views, plus calls to the CWM2 PL/SQL API. However, OLAP will be releasing an AW Manager tool
    that makes this process easier. Please contact OLAP Product Management for further details.

  • How to use a custom servlet in iFS?

    Hi,
    I'm creating a custom servlet to download files from iFS to local drive. My question is where should I put the servlet class file, and how do I invoke this servlet from a ifs jsp file?
    I'm running iFS 1.1.9, with JWS web server.
    Thanx.
    [email protected]

    Howdy:
    In the iFS Online Resources HTML whitepaper,
    there are several examples for creating and
    deploying servlets. See the section "Creating a Simple Content Management Application." Please check out: http://technet.oracle.com/products/ifs/htdocs/resources/index.htm
    Hope this helps,
    Dennis Dawson

  • How to use value returned from a bean in jsp page

    Hi All,
    I have a string array value being returned from a javabean to a jsp page. I want to be able to assign the value to a variable in the jsp page.
    How do I do this?
    Many thanks :)

    thanks for your response.
    I actually used something like this:
    <% String loggedin = log.User(user,password);
    out.println(loggedin);
    %>i am not yet as much of an expert on beans as i would like to be, but i thought it is not really a bean if it has a getter method which takes arguments?

  • How to use css in servlet

    out.println("<link rel='stylesheet' type='text/css'");
    out.println(" href='style_shop.css' />");
    i typed above statement in a servlet
    but still doesn't show the style how i can fix it?
    Message was edited by:
    takamai

    is style_shop.css in the correct path on the server?
    If you are using a war file it should be in the root folder of the war.
    or try to give
    out.print("<link rel='stylesheet' type='text/css href='");
    out.print(request.getContextPath() + "/style_shop.css' />'")

  • Help: how to use valuechangelisteners in a baking beans

    <h:form id="selectCurriculum" >
    <h:selectOneMenu id="selectlinks"
    valueChangeListener="#{CurriculumManager.selectCurriculum}"
    required="true"
    >
    <f:selectItems value="#{Curriculums.items}" />
    </h:selectOneMenu>
    <h:commandButton action="selectItem" value="&#1087;&#1086;&#1082;&#1072;&#1079;&#1072;&#1090;&#1100;" />
    </h:form>
    method selectCurriculum() is not called

    public void selectCurriculum(ValueChangeEvent event){
    logger.info(event.getNewValue().getClass());
    Integer id = (Integer) event.getNewValue();
    Collection curriculums = curriculums().getCurriculums();
    ObjectCurriculum curriculum = null;
    for (Iterator iterator = curriculums.iterator(); iterator.hasNext();) {
    ObjectCurriculum objectCurriculum = (ObjectCurriculum) iterator.next();
    if(objectCurriculum.getId().equals(id)){
    curriculum = objectCurriculum;
    break;
    curriculum().setWholeObject(curriculum);
    logger.info("setting current curriculum");
    no message is logged

  • How to use multithreading to access sensor data?

    I'm trying to access sensor data on another thread but keep getting error - No overload for 'OnSensorChanged' matches delegate 'System.Threading.ThreadStart' What am I doing wrong?
            public string str
    { get; set; }
            public void OnSensorChanged(SensorEvent e)
                if (e != null)
                     str
    = e.Values [2].ToString("0.0");
            public void button_OnClick (object sender, EventArgs eventArgs)
                Setup setup = new Setup();
                Thread newThread = new Thread(new ThreadStart(setup.OnSensorChanged));
                newThread.Start();
                newThread.Join();
                newThread.Abort();
                       _text.Text = str;

    Hi Kringle,
    >>No overload for 'OnSensorChanged' matches delegate 'System.Threading.ThreadStart'
    This exception indictates that the method signature for OnSensorChanged does not match the signature defined by a ThreadStart delegate. You need to pass a SensorEvent object into this method, for example:
    Thread newThread = new Thread(setup.OnSensorChanged);
    newThread.Start(new SensorEvent());
    Reference:
    https://msdn.microsoft.com/en-us/library/system.threading.parameterizedthreadstart%28v=vs.110%29.aspx
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to use TopLink's mapping info at runtime

    Can anybody kindly instruct how to do the following:
    1) Once the "JavaSource.java" file or the "ProjectDeployment.xml" file is generated by TopLink from a TopLink project, how can it be included and used in a J2EE project at runtime? I understand that this step may be specific to the type of IDE used, let us say WebLogic, WebSphere or JDeveloper9i.
    2) Can TopLink generate the file "sessions.xml" automatically or it has to be hard-coded? Does this file have also to be included in a J2EE project under the directory of META-INF at runtime?

    Hi John,
    Probably the best way I can explain the process of putting a J2EE app with TopLink into production would be to describe the best practices of doing so.
    Firstly, I recommend using an IDE to develop your Java source code, although it is possible to generate Java source directly from the Mapping Workbench, this is considered more of a rapid prototyping or quick start process. Once the Java source has been compiled, the Meta-Data (project.xml) can be deployed from the Mapping Workbench.
    The next step really depends on the type of application you are creating. Since you are developing a J2EE based application and it will be multi-user, TopLink recommends using a ServerSession architecture. (Consult the documentation for detailed explanations). Configuring the session can be done in a number of ways, the best way would be to use the SessionManager and an external file called sessions.xml. Both the sessions.xml and project.xml must be visible by the J2EE component that will be using it. (Servlet/Session Bean, etc...). This is done through managing your deployment properly using something like an EAR.
    The key to getting the application and TopLink working together is the session, and here's a basic example on how you could set this up:
    sessions.xml code:
    <toplink-configuration>
         <session>
              <name>myProject</name>
              <project-xml>myProject.xml</project-xml>
              <session-type>
                   <server-session/>
              </session-type>
              <connection-pool>
                   <is-read-connection-pool>false</is-read-connection-pool>
                   <name>default</name>
                   <max-connections>10</max-connections>
                   <min-connections>5</min-connections>
              </connection-pool>
              <enable-logging>true</enable-logging>
         </session>
    </toplink-configuration>
    Somewhere in your application code, you might have a login method that makes use of the SessionManager to load and create the session:
    SessionManager sm = SessionManager.getManager();
              Server serverSession = (Server)sm.getSession("myProject", this.getClass().getClassLoader());
    The sessions.xml must be created manually at this point, a future version of the TopLink product will contain an editor which will help out.
    Darren Melanson

  • How to use BOLD Fonts/text in Oracle?

    Hi guys,
    Im doing a package and part of this package has an email to a client. I just want some details of that email should be BOLD fonts/text like the Name or Title. Can anyone help me solve this problem?
    Im using Oracle Forms6i and Oracle9i for our database.
    Thank you.
    Lala

    Hi,
    How about using a [Rich Text Editor bean|http://forms.pjc.bean.over-blog.com/article-28390950.html] (in place of a text item / text area)?
    -Arun

  • How to use JMS in a J2EE environment

    Hello all,
    I would like to find out how to use JMS in a J2EE environment. I use Borland Enterprise Server. Do I need to buy a message software to use JMS? How to use JMS with Message Driven bean?
    Thanks a lot.
    Best regards
    Susan

    If you don't want to buy you could try OpenJMS, a free JMS product (http://openjms.sourceforge.net/)
    As for learning how to use JMS w/ MDBs, I would suggest grabbing a book on JMS. I found the OReilly book on JMS to be pretty helpful for me.

  • How to use a Webservice (deployableproxy) within a portal component?

    hi,
    i need to know how to use a webservice using a deployable proxy within a portal component?
    i've created the proxies and they work (with servlets).
    i know how to use them in servletes (context lookup, jndi mapping, application references) but i cant find a way to use them in a portal component.. tried the context lookup way but cant figure out which jndi mapping to use.
    any help?
    thanks in advance,
    constantin

    i've found this document:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/cb2e29578c0262e10000000a11466f/frameset.htm
    but it doesn't help...
    i should add a privatesharing resource...
    <property name="PrivateSharingReference" value="SAPJ2EE::rh21.de/pca~wsproxy"/>
    which works
    this is my code
    public void doContent(IPortalComponentRequest request,IPortalComponentResponse response) {
       try {
         Context context = new InitialContext();
         WSPhonebook obj = (WSPhonebook) context.lookup("/wsclients/proxies/rh21.de/pca~wsproxy/de.rh21.wsproxy.phonebook.WSPhonebook");
         WSPhonebookViDocument phonebook = (WSPhonebookViDocument) obj.getLogicalPort("Config1Port_Document", WSPhonebookViDocument.class);
    } catch.....
    now the lookup works (i guess, no messages about that anymore), but i catch ClassNotDefFoundError-Exceptions, but the classes are there, i can strg+click them in the editor, they are in the used dc's etc.
    any help? its quite uurgent :/

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

Maybe you are looking for

  • NULL Value in SAP Business Connector  (BC47_CoreFix7 )

    Dear All, I am working with SAP Business Connector and some times i get NULL value in (PROXY SERVER) in Secure Proxy (HTTPS) so i need usualy to remove it manully and save the changes. Would you plesae help me to solve this issue either to delete aut

  • How to set group contacts in nokia asha 305

    how to  set group contacts  in nokia asha 305....thank u......

  • Adding contacts to address book

    Hi how can i add contacts to personal as well as system address book using SOAP API.

  • Where is located a query????

    I'm new in this forum and new in java world; i'm testing a crm java based (in tomcat server): my problem is related to know what files contains query text because i discovered a bug in a query (when i try to execute this query tomcat server make a lo

  • IPC filters limitations?

    Hello all. We need to download from R3 to IPC informations about a catalog with about 1000 materials. For this is set two filter files for ipc for product data and for condition data. Initially the product file looks something like. range=MARA,MATNR,