/** * Servlet implementation class InvoicingDeptServlet */ @WebServlet("/InvoicingDeptServlet") public class InvoicingDeptServlet extends HttpServlet { private static final long serialVersionUID = 1L; //Make arraylist global object ArrayList<InvoiceData> invoiceList = new ArrayList<InvoiceData>();
In our web application we are using servlets,jsp and spring technologies.Here we are also maintaining session mechanism in our application.But now i need to count number of users accessing our web application at a time. How can i implement this mechanism...
For one of my project, required to capture the audit history reports of all the activities of the users within the application. We are using Servlet/JSP in J2EE environment.
For Ex: Whenever user updates some fields, we need to capture the Old value, new value, user id and time stamp. We have single form with more than 200 fields.
Just want to know the best way to do this..any frameworks available for it...or doing at the database side like using triggers..
It sounds simple enough, but I'm trying to implement a mechanism to prevent the same user logging into our distributed web application simultaneously.
So, given the scenario... - user A logs in with username A - user B logs in with username A
I want the logging in of username A by user B to invalidate the session for username A held by user A. So if people are sharing login credentials, the last person to log in kicks everyone else out who's logged in as that user.
The big problem I have is the application is deployed in a cluster across JVMs, so sessions are shared across nodes. My thought it to introduce a session listener to then inspect a table in the database which determines whether that user logged on - the part of identifying that is pretty simple as far as I can tell. The difficult part is kicking out the first user who logged in.
So, I guess my question is - can I invalidate an http session from with an MDB? If so my logic is to implement an MDB which listens on a topic and whenever a session is created that MDB checks for sessions belonging to the same user within that JVM to invalidate them (obviously skipping the JVM the login request came in on!).
Is that even possible? Is there a simpler way to do this?
I'm just starting up with Java Mulithreading.Below is the repo I set up, and I am having trouble with this test I am doing playing around with Executor threadpools. I am trying to setup a managed system where I first add some lines to be printed, then add the work to the work pool, and then finally launch n number of threads to handle the work (or in this case, print out the strings I added to WorkManager instance fields). I watched this series of videos starting with this one: URL...., and I planned on playing with the concept of multithreading, but it doesn't seem to work and gets stuck at Thread1:27. I thought that by synchronizing access to the ListIterator return, that it would not block. URL....
My java application is blocking from time to time. I have added some log lines and now I know exactly where is blocking, but I have no solution to fix it.
This code runs in a parallel thread, distinct from the main application thread and updates a big JTextArea swing:
try { .... JTextArea element = (JTextArea)add_containers[objColIndex]; System.out.println("setEditValue start seting text "); element.setText(VAL); System.out.println("setEditValue text is set ");
[Code] ....
The code reaches "setEditValue start seting tex" but never reaches "setEditValue text is set". No exception is triggered. The whole application is blocked - main thread and this paralel thread. This section of code is called many times, but in rare cases is blocking without any apparent reason. Sometimes I run the exact same instructions and is blocking and sometimes is working.
I set the limit to 2 so the producer blocks after two insertions until an item is consumed. Because we are dealing with a basic counter that increments, we do not lose any data. Since after queue is freed up we simply increment by 1, so we are able to store all numbers. However, in real world situation, you might be storing data coming from redis server into the queue. And redis server may be publishing a plethora of data. So when the queue blocks, and new data comes in, what happens? Is the currently blocked data lost forever and the new data that came in is now blocked, or is the new data that came in ignored and the old data remains being blocked until queue is freed up?
Java Code:
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; public class BlockingQueueBlocking { private BlockingQueue<Integer> sQueue = new ArrayBlockingQueue<Integer>(2); int counter=0; private void test() throws InterruptedException{
Me and my brother decided to make a relatively simple client/server program where clients get into a simple chat lobby and can invite others to play small games(like pong). The basic server code has been written, and we have made a special client that is used for debugging.
We use a self-defined protocol of Strings where a message looks like "4-|user,pass". The number before the delimiter "-|" is the operation code, that tells the server what kind of message this client sends. Based on that number, the server dispatches the message to the appropriate handler method. 4 is authentication for example, and the handler looks the user and pass up in a file and if found, returns true, otherwise, false. Then the server responds to the clinet with 2-|"any message" where the client will recognize opcode 2 as a "authentication accepted" and proceed with the next part of client code. In a similar way, we plan to write all message types(both in the game, in the lobby and in a game setup room).
While testing we ran into a problem where the BufferedReader .readLine() does not seem to be a blocking call like it should be, so the client keeps spamming 'null' in the output field that we made to see the server response to the message we send. When we try to debug the server code and set breakpoints at the suspicious locations, it strangely skips both while(true) loops without activating either breakpoint and executes the finally{} code, even though the client did not close the connection and the second while loop was never entered. The first while loop IS entered though, because the test client gets a "0" on its output, which is the server message indicating "please authenticate yourself".
We decided to use messages in a string format and decode it at both sides as it seemed easier than transmitting java objects and making sure they are of the same type, also for reducing overhead as much of possible.URL....
What's up with this. Just trying to test my hands on java packages, and had this error(by java) after successful compilation:
Error occurred during initialization of VM java.lang.Error: Properties init: Could not determine current working directory. at java.lang.System.initProperties(Native Method) at java.lang.System.initializeSystemClass(System.java :1119)
Main.java
package com.aceix.simplecalc; import com.aceix.simplecalc.inputhandler.InputHandler; import com.aceix.simplecalc.mathoperation.MathOperation; public class Main { public static void main(String[] args) {
And in the server log there is a long list of comments, the first which looks to be of significance to this issue is:
WARNING [http-apr-8080-exec-57] org.apache.catalina.deploy.NamingResourcesImpl.cle anUp Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/transBoard]] so no cleanup was performed for that container javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp].
There are others further down the list which might also be significant such as:
SEVERE [http-apr-8080-exec-59] org.apache.catalina.core.ContainerBase.addChildInt ernal ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/transBoard]]
The corresponding line of code for the first warning that I listed is for the DataSource object and I wrote it as follows:
Currently my application is on Tomcat5.0.16.I use struts1.2, jstl 1.1 , jsp-api 2.0.I tried to migrate my application from tomcat5.0 to tomcat 6.0.26.I didn't see any issue in deployment but when i tried to access jsp pages i got this exception.
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /pbuilder/login/legacyLogin.jsp(6,4) Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88) org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:297)
[code]....
i found that jstl1.1 jar didn't have the above mentioned class.I replaced jstl1.1 with jstl1.2 jar.i verified that jstl1.2 jar had JstlCoreTLV calss.but even after this replacement of jar i am facing the same issue.
I don't get an in code error but when I run this one it crashes at the print line "failed conversion error". I've used this style format in another program and format worked ok, what doesn't it like
public class Commission { /** * @param args the command line arguments */ public static void main(String[] args) { // Calculate Commission and payment due double subtotal; double granuity; double paymentDue;
I am trying to run my program through netbeans and I get a message: build-impl.xml:1048 the module has not been deployed. see the server log for details.The corresponding line in the xml document is:
And in the server log there is a long list of comments, the first which looks to be of significance to this issue is:
WARNING [http-apr-8080-exec-57] org.apache.catalina.deploy.NamingResourcesImpl.cleanUp Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/transBoard]] so no cleanup was performed for that container javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp].
There are others further down the list which might also be significant such as:
SEVERE [http-apr-8080-exec-59] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/transBoard]]
The corresponding line of code for the first warning that I listed is for the DataSource object and I wrote it as follows:
the issue has something to do with connecting to the database since it ran fine before I added the database related code.
update: my server.xml file is as follows:
<?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership.The ASF licenses this file to You 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
My code compiles successfully, but when executing I never get an output, and then the message: ">Process failed to respond; forcing abrupt termination...". Is there an infinite loop in my ab method, is that why?
public class Test{ boolean ab(String s){ boolean seenAnA=false; while(true){ if(s.charAt(0)=='a'){ seenAnA=true; s=s.substring(1);
There are few modules in our application whose performance degrade with time when 50-100 simultaneous users are working on them at a given instance.The memory allocations are taken care of to allow maximum data.My issue to where to start finding the root cause.
I am currenlty using JvisualVM for profiling and finding memory leaks..Do i need to Simualte 50-100 virtual users and start finding the memory leaks with JvisualVM or working with a single user would do ?
A University offers a course that prepares students for the county licensing exam for real estate brokers. Last year, twenty students who completed this course took the exam. The university wants to know how well its students did an exam. You have been asked to write a program to summarize the results. You have been given a list of these 20 students. Next to each is written a1 if the student passed the exam or a2 if the student failed the exam.Your program should analyze the results as follows:
i.Input each test result (i.e., a1 or a2). Display the message Enter result on the screen each time the program requests another test result. ii.Count the number of test results of each type. iii.Display a summary of the test results, indicating the number of students who passed and the number who failed. iv.If more than 15 students passed the exam, output message, Bonus to the instructor
I'm doing a problem where I convert users input for the date (MM/DD/YY) into a written out date and year. That part is fine. The part I'm struggling with is then indicating what day that is in that year. how to use the user inputted MONTH, DAY, and YEAR to then get the day of year.
import java.util.Calendar; import java.util.Scanner; import java.util.regex.MatchResult; import javax.swing.JOptionPane; public class ConvertDate {
I have created this project and want to be able to add new members to my members arraylist, store the input in a .txt file and load the new members after closing and opening the program.