w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Session replication in Tomcat - jdbc session persistence - custom or library implementation?
Take a look at this: http://www.intelligrape.com/blog/2010/07/21/tomcat-6-session-persistence-through-jdbcstore/. I'm trying to do the same thing as you, I found that this works. However, I experience a delay on the DB session insert. If you use that solution and found an answer to it let me know.

Categories : Java

Start and stop logging terminal output to file from within bash script
You can use the braces to redirect commands to tee through a pipe #!/bin/bash # to terminal and logfile.log { echo "aaa" echo "bbb" echo "ccc" } 2>&1 | tee logfile.log # only terminal echo "ddd" echo "eee"

Categories : Bash

Tomcat, User Session Storage with JDBCStore, Immediate Session Timeout
You need to check a couple of things... Verify that tomcat is actually connecting to the database at all Then once you are sure it is connecting.. does the user have access to update the table tomcat_sessions If you want to add data to the session then all objects need to be serializable or they won't be reloadable Hope this helps

Categories : Java

Detect version of tomcat when WAR file starts (possibly stop it if it is not on the recommended version)
Straight from Tomcat FAQ: How to I get Tomcat's version number? javax.servlet.ServletContext.getServerInfo(); Starting with Tomcat 5.0.28 - there is now a version.sh (or version.bat) program in the bin directory. It will print the version number of Tomcat to Standard output.

Categories : Tomcat

Maintaining same session after browser closes and reopens in struts2
To solve your problem you will have to work with persistent cookies. Persistent cookies are ones which are stored even after the user closes the browser. The folowing link should be helpful: Using cookies with Struts 2 and Struts

Categories : Java

How to open a bash/ssh session in shell script and run commands in the remote session?
Take a look into expect, which "talks" to interactive programs with the help of a user provided script. Usage expect ./interact or making interact executable (chmod a+x interact): ./interact where interact is the following script: #!/usr/bin/expect spawn ./a.out send -- "yes " expect "3292 " send -- "no " This is just a simple example, the man page is full of in depth explanations and there are also example scripts which come with the installation. References http://linuxaria.com/howto/2-practical-examples-of-expect-on-the-linux-cli?lang=en Best way to interact with a service for exploitation purpose

Categories : Linux

Stop a running application tomcat server
You could implement your job so that it periodically checks if it's allowed to continue. This is best practice for long-running jobs anyway. If that's in place, you can easily provide a UI for the feature - be it on application restart or individual per job.

Categories : Tomcat

Tomcat session expired handling
If you are using a Servlet, then you will throw java.lang.IllegalStateException. When you try to use your session. If you are using a JSP, then you will throw NullPointerException. When you try to access a session attribute that was lost with the old session.

Categories : Jsp

SessionListener for session modification in Tomcat
Take a look at HttpSessionAttributeListener This listener interface can be implemented in order to get notifications of changes to the attribute lists of sessions within this web application. Please, note that while it could notify you about new objects getting bound or removed; it won't notify changes done to properties or elements of an already bound object (say, if you add another element to an ArrayList). It would however notify if the `ArrayLlist is replaced. public class SessionModifcationListener implements HttpSessionAttributeListener { @Override public void attributeAdded(HttpSessionBindingEvent se) { } @Override public void attributeRemoved(HttpSessionBindingEvent se) { } @Override public void attributeReplaced(HttpSessionBindingEvent s

Categories : Java

how to detect tomcat session expiration using spring
You can use a listener class to achieve this. Define a listener component as below: @Component public class AppLogoutListener implements ApplicationListener<SessionDestroyedEvent> { @Override public void onApplicationEvent(SessionDestroyedEvent event) { // from event you can obtain SecurityContexts to work with } } You need to define a session event publisher in your web.xml: <listener> <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class> </listener> Here the HttpSessionEventPublisher publishes the session life cycle events whenever sessions are created and expired.

Categories : Spring

Getting Session Object in Tomcat Custom Realm
The way I always do this is with a Filter that runs after the authentication has been completed. If the HttpSession contains a user token, then I do nothing and call-down the chain. If the HttpSession does not contain that user token, I do everything I need to do to set-up the session using the Principal available from the request (because authentication has already occurred). It doesn't sound like this really needs to be part of authentication (the Realm), so separate the two.

Categories : Tomcat

Tomcat session cookie doesn't expire
The cookie is held in the browser - when the server restarts, but the browser continues to run, it will hold onto the cookie and present this to the server on next request. Now on the server side, you have multiple options: You can configure tomcat's SessionManager to persist on disk and read the content upon restart - this is an option that also is used to distribute sessions between multiple tomcats in a cluster: When the session is serialized to disk, any server can continue the session by "just" deserializing it. There's some cost implied (as you constantly need to serialize sessions) Currently I can't give you more concrete hints than this - but if you look it up and understand the difference between where the cookie is stored, why it doesn't change on server restart and that you'll

Categories : Java

Unable to start a tomcat debug session from Eclipse
I solved my issue : there were a packet inspection activated on the firewall between my PC and the server. It lets certain TCP packets trough, so the TCP handshack can occure, but block data TCP packet. As I understand, first, a TCP connection is made, then an application handshake is done by the java server with TCP data packet. As data packet was filtered by the firewall, the application handshake could not been completed, and the application close the TCP connection by sending a FIN packet. Regards, Robert

Categories : Eclipse

Tomcat 7 session times out but postgres sql connection stays active
That depends on how the application access the database. If the application accesses the database directly by managing its own connection pool, then there's nothing that Tomcat can/will do to release abandoned connection. If the application accesses the database through a connection pool that is managed by Tomcat, then the connection pool can be configured to get rid of abandoned connections: http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html Proper application development calls for relying on the container for providing JDBC connections, so if your vendor designed their application well, then just configure the connection pool accordingly. However, as you were mentioning that your vendor has been researching this issue for months, it's quite possible that the application goes dire

Categories : Java

Sharing session attributes of a web service and a servlet within same Tomcat container
The fact that your class test.main.StoreCreds implements an interface com.data.credentials.manager.IFStoreCredentials doesn't change the fact that your object is still an instance of the concrete test.main.StoreCreds. And if the wabapp doesn't know about this concrete class, it can't use an object of this type, because it can't find the byte-code of the class of the object, which is obviously needed to use it. The concrete class must be shared by both applications. That said, shared sessions is not standard, and should be avoided. Consider making it a single application, or storing the data you want to share between apps in a shared database.

Categories : Java

stop bash from expanding * in sql statement
How about echo "delete * from table_name" | sqlplus or echo "delete * from table_name" > mystatements.txt sqlplus @mystatements.txt On a side note, you don't need to specify * in a delete statement - all fields in the matching rows are deleted.

Categories : Bash

How to create .log file for each session and how to store that particular session data in .log file?
I don't know if you can do this directly with log4j, or any of the logging frameworks, but it sounds like what you need is an "audit" log. The way we handled it was to create a custom annotation, @Audit, that we could apply to a method that needed to be audited. In our case, we didn't write to a log file, but rather stored the audit record into a DB table. You could easily setup your own annotation that used Log4J with a custom appender that wrote lines to a particular logfile. Such a annotation might look like: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Audit { // Put any custom parameters here for your annotation } And then you need some way to "read" those annotations later. We chose to use AOP like such: @Aspect @Component("auditAdvice"

Categories : Hibernate

Stop div from showing more than once per session or visit
This will be persistant as long as the web browsers cache is not cleared. Here is my reference link: http://www.w3schools.com/html/html5_webstorage.asp You could try this: $(document).ready(function(){ // Checks to see if it is the first visit on browser open if(sessionStorage.firstVisit != true) { // Stores visit sessionStorage.firstVisit = true; $('#panel').show(); } else { $('#panel').hide(); } $("#close").click(function(){ $("#panel").hide(); }); }); The session storage will stay loaded per visit to the website. An alternate solution would be to keep it based on forever, so if you want them to only see it if it's their very first time to visit the website from that machine: $(document).ready(function(){ // Che

Categories : Jquery

How to stop git hanging on commit in cygwin bash
The hanging was caused by git being unable to find my editor when I set the global editor to notepad git config --global core.editor "notepad" Then everything works fine. By setting the global editor to the windows location of vim git config --global core.editor "c:/APPS/CYGWIN/bin/vim.exe" I was able to run vim and then I could see that there was a lock file as well.

Categories : GIT

Stop bash script without command line
I think it is a little bit overcomplicated. Actually you do not need to start bash as it is started when You start ./executeServer.sh. Add executable rights to ./executeServer.sh and start it as it is. And do not need to start it in the background, as it already starts Server in the background in the script.

Categories : Bash

stop bash script from outputting in terminal
Append >> /path/to/outputfile/outputfile.txt to the end of every echo statement echo "Process is running." >> /path/to/outputfile/outputfile.txt Alternatively, send the output to the file when you run the script from the shell [~]# sh check.sh >> /path/to/outputfile/outputfile.txt

Categories : Bash

execute user inputed Windows (or bash) commands from batch (or bash) file?
Do you need a full bash prompt? Or would something like this be enough? #!/bin/bash echo -n "Enter cmd: " read COMMAND echo ${COMMAND} | bash Also, in a script, you can just execute bash and get a full prompt in the current environment.

Categories : Bash

How to stop a script running in a tmux session?
From https://gist.github.com/henrik/1967800: tmux kill-session -t myname You can also run a command with it's input from a named pipe (created using mkfifo). Check out http://www.catonmat.net/blog/bash-one-liners-explained-part-three/

Categories : Bash

How does this bash code detect an interactive session?
${parameter#word} ${parameter##word} The word is expanded to produce a pattern just as in filename expansion. If the pattern matches the beginning of the expanded value of parameter, then the result of the expansion is the expanded value of parameter with the shortest matching pattern (the ‘#’ case) or the longest matching pattern (the ‘##’ case) deleted. If parameter is ‘@’ or ‘’, the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant list. If parameter is an array variable subscripted with ‘@’ or ‘’, the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list. Source: http://www.gnu.org/software/bash/manual/html_node/She

Categories : Bash

bash script to write content into file. File content requires bash variables. How to do that?
You're actually deliberately turning off parameter subsitution by enclosing 'ENDFILECONTENT' in quotes. See this excerpt from example 19-7 of the advanced Bash scripting guide on Heredocs, slightly reformatted: # No parameter substitution when the "limit string" is quoted or escaped. # Either of the following at the head of the here document would have # the same effect. # # cat <<"Endofmessage" # cat <<Endofmessage Remove the single quotes around 'ENDFILECONTENT' and BASH will replace the variables as expected.

Categories : Bash

CMD lines work fine but not in .bat file, it just instantly closes?
Why not with the pause command? -alternatively put cmd /k on the very last line of your script. cd /d "D:JavaProjectsJasper andom-jasper-lib" start /b "" "mvn" clean install cd /d "D:JavaProjectsJasper andom-jasper" start /b "" "mvn" clean install cmd /k

Categories : Batch File

How to configure tomcat web.xml and tomcat-users.xml to secure a tomcat page
As far as access to the tomcat manager GUI is considered, there is no role as "manager" to set in tomcat-users.xml. you have to specify one of these roles. You can find the role names in the web.xml file of the Manager web application. The available roles are: •manager-gui — Access to the HTML interface. •manager-status — Access to the "Server Status" page only. •manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page. •manager-jmx — Access to JMX proxy interface and to the "Server Status" page. have a look into this link for further info, http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html I hope it helps, thanks.

Categories : Xml

Stop avconv Bash script on user input and continue loop
UPDATED Try something like this (OP's code modified a little bit): #!/usr/bin/bash stop() { [ $CPID -ne 0 ] && kill -INT $CPID && wait $CPID && echo "Killed $CPID"; } trap "stop; exit" INT CPID=0 while :; do read -p "Enter your number here: " YOURNUMBER stop [ "$YOURNUMBER" == quit ] && break; TIMESTAMP=$(date +"%Y.%m.%d_%H.%M") avconv -f video4linux2 -r 3 -fs 52428800 -i /dev/video0 /home/$USER/orders/$YOURNUMBER/$TIMESTAMP-$YOURNUMBER.avi& CPID=$! echo -e "Video complete!" done This starts avconv in the background so the user can enter a new number. Maybe the stdout and stderr of avconv should be redirected to a log file or to /dev/null. Also it should be tested which signal stops avconv gracefully. -INT is equivalent to ctrl+c. It

Categories : Bash

Create a histogram or frequency list of most popular commands used in bash session
You can parse the output of the history command, and count occurrences of the command field. history | awk '{print $4}' | sort | uniq -c | sort -n Will print a list of executed commands and the amount of times they were executed. Then, you can fetch the total amount of commands executed with history | wc -l, and then perform the calculations.

Categories : Bash

How to write a bash script that can parse through an XML file as input and remove certain elements from the file
Perhaps you could use php like this: running php script (php function) in linux bash And then you something like domdocument(http://php.net/manual/en/class.domdocument.php) to read and the right the xml. Of course this is assumes you have php installed.

Categories : Xml

how to start a session by adding a link and end the session in the same way and showing session datas
Here is how you can end the session with a link, by passing a $_GET parameter <a href="?logout"> Log out </a> <?php if(isset($_GET['logout'])) { session_destroy(); } ?> It is worthy to note, that you must have already started the session with session_start() before destroying it.

Categories : PHP

Pass content of file in variable into bash script - without writing the file down
You need one more <: ./script -a <<<"$CONTENT" <<< is called a herestring, and takes the following string and passes it as the standard input.

Categories : Linux

Tomcat redirecting to old file
Maybe there's something like a TTL (timeToLife) that makes the server output the same as some minutes before. If the TTL is one hour it would output the same for an hour. Only after this hour it would update the answer-file. Check out something like TTL configurations of your tomcat server.

Categories : Java

Need help in put war file into Tomcat using ant installer
You need to create user in tomcat-users.xml <?xml version="1.0"?> <tomcat-users> <role rolename="dbadmin"/> <role rolename="manager"/> <user username="BruceP" password="bwperry" roles="dbadmin,manager"/> <user username="JillH" password="jhayward" roles="manager"/> </tomcat-users> Create the build.properties file appserver.home=c:\apache-tomcat-7.0.19 appserver.lib=${appserver.home}/lib deploy.path=${appserver.home}/webapps tomcat.manager.url=http://www.localhost.com:8080/manager tomcat.manager.username=username tomcat.manager.password=secret Create the build.xml file <?xml version="1.0"?> <project name="fax" basedir="." default="usage"> <property file="build.properties"/> <pro

Categories : Java

Tomcat 7 - use in in web.xml
This works fine for me in same environment (eclipse + Tomcat 7). Maybe you should check the web.xml schema version? I'm using this : <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> ... </web-app>

Categories : Jsp

Why i can't see my js file from browser - tomcat 7
You can't place JS files or any publicly accessible data inside the WEB-INF folder. You need a JS folder in the same directory as your WEB-INF folder and that is where you place them. The same goes for your .css files and your images. None of that can be seen from inside WEB-INF. /WebApp/CSS/index.css /WebApp/JS/index.js /WebApp/WEB-INF/index.jsp /WebApp/Images/logo.png

Categories : Java

linux Bash - read contents of file , store them in a variable and create network config file
I tried yesterday and I am very close to the solution. Researching the internet , I made a perl script and was able to create multiple interface by extracting data from csv file. But there is small issue I see and not able to figure out why an extra character is coming in the file. Following is the code: #!/usr/bin/perl use strict; use warnings; sub main { # Note: this could be a full file path my $filename = "file1.csv"; open(INPUT, $filename) or die "Cannot open $filename"; # Read the header line. #my $line = <INPUT>; my $line; # Read the lines one by one. while($line = <INPUT>) { chomp($line); # Display the header, just to check things are working.

Categories : Linux

Bash shell read names of files from folder and create an output file for each input file with the same name:
The underscore is a valid character in variable names. Do: ./"$f" > "${f}_july_15.txt" Your code was trying to use a variable named f_july_15. You need to use braces to delimit the variable name when it's followed by a character that can be part of a variable name.

Categories : Bash

How to use external file as a source of variables for Bash script file?
Save this to a file e.g. script.sh. #!/bin/bash declare -A A while read -ra __; do A[${__[0]}]=${__[1]} done < "$2" while read -r __; do for I in "${!A[@]}"; do [[ $__ == *"$I"* ]] && { V=${A[$I} __=${__//"$I"/"$V"} } done echo "$__" done < "$1" Then run bash script.sh aaa.txt bbb.txt. To get the output run it as something like bash script.sh aaa.txt bbb.txt > out.txt I prefer to use Bash this time since you have to quote non-literals in Awk. Another solution through Ruby: ruby -e 'f = File.open(ARGV[0]).read; File.open(ARGV[1]).readlines.map{|l| l.split}.each{|a| f.gsub!(a[0], a[1])}; puts f' aaa.txt bbb.txt Another way to modify file directly: #!/bin/bash A=$(<"$1") while read -ra B; do A=${A//"${B[

Categories : Bash

how to access tomcat servlet in maven project structure with embeddable tomcat
Your application context path is /Archery (defined in context.xml) Your servlet path is also /Archery (urlPatterns property of @WebServlet) It's also duplicated by your web.xml So, your URL should be localhost:8080/Archery/Archery First server[:port], followed by context path, followed by servlet path Anyway, you will have to fix project structure in order for this to work. If you are following Maven conventions web resources directory should be src/main/webapp The web.xml (and context.xml) should be put under WEB-INF directory under this directory. After you have packaged the war, just make sure these files are there (under WEB-INF)

Categories : Maven



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.