masijade 1,351 Industrious Poster Team Colleague Featured Poster

Your exit status from your java program is whatever number you place
in the System.exit call. There is no standard exit code value other than
0 is successful and not 0 is an error. I would say you are probably pretty
safe using return codes between 50 and 200, just a personal guess. I
have never actually seen the jvm die with an error code other than 0, 1,
254, or 255.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The application server specific stuff in the tutorial is its description on
how to deploy the examples on a sun one application server. Other than
that, everything is standard j2ee. And the reader should hopefully be
able to read the server documentation well enough to find out how to
deploy an application, especially when a war file is provided.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The only java method you can call from a shell script is the main method
of a class, by starting that class with a java command line execution.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I would, however, say that you probably made a bad purchase. I cannot
believe a book that calls itself "Fundamentals of Java", and then goes
about using a load of non-standard, and falsely coded, packages can be
all that good. Maybe it is, but I would at least be wary.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Did the book come with a CD? Or does it have all these non-standard
packages maybe written uot in an appendix or something. Or can you
look at the references and find out if it says where they might be downloaded from.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I have never heard of that package, and somehow I doubt that the book
spelled it that way, since package names are suppossed to be all lower
case. Also, it was never a part of the JRE, since all those packages start
with either java, javax, com, sun, or org.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you mean passing a variable that only exists as a javascript variable,
you cannot. What you can do, however, is to provide a hidden input
field in your form, and write the value of the variable to this input field
before you submit your form.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

My personal opinion is the one you have already mentioned, PerlTk.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Javascript runs on the client, JSP runs on the server. They cannot
communicate with each other directly. If you are advanced enough, look
into a servlet web service and AJAX to solve your problem, if it must
absolutely be dynamic. Otherwise, you are going to have to submit your form.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

on the login page, you create a session as follows:

HttpSession session = request.getSession(true);

this will create a session if none exists.

During the rest of the users activities, all other pages should use the
following:

HttpSession session = request.getSession(false);

This will return null if there is no valid session. So check for this.

If anything happens (i.e. the login fails or you go to the logout page),
do the following:

session.invalidate();

This will invalidate the session so that further getSession calls using false
return null.

This is the basic session process/life cycle.

The login itself, you can still do yourself, and if it fails, just invalidate
the session, as mentioned above. If it succeeds, then continue with the
site, and on the logout page, invalidate the session again.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I assume your login assigns a session. If so, than on logout do
session.invalidate() Pushing back on the browser may still show the
site but it should only be a version of the site in the cache. If the user
tries to actually submit anything, or reload the site, it should not work.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By doing exactly what ypu are doing, but storing the result of the
executeUpdate in an int rather than a ResultSet. You can then check
that the integer is not 0 if you want to make sure that something was
inserted. After you have made this change, try your program again.
If nothing is being inserted, you will at least, probably get a better
error message than the one you are getting now. This error message
is being thrown during compileation. Up to this point, nothing has been
executed.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

executeUpdate returns an int indicating the number of rows affected
by the query. It does not return a ResultSet.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
#!/bin/ksh

tail -f file.log | grep "ERROR" | \
while read line
do
  echo $line | mailx -s "Error" you@office.com
done
masijade 1,351 Industrious Poster Team Colleague Featured Poster

I have no idea about bioinformatics, but a good starting point for perl for
a true programming newbie is "Learning Perl" from O'Reilly publishers.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I am pretty sure you cannot. Trying to intercept the shutdown call,
seems to me, to be a pretty system-level function, and Java is not
intended, or designed, for that type of functionality.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What problem are you having? Or are you just simply asking to have
us program this and just give it to you?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Thanks for pointing that one out. I haven't tried compiling from
within a program yet, and really don't have a clue as to what project I
would have to be on to make it neccessary, but I may have to take a
look at that and try it out, just for fun.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just a note, you can do this, and many people do, but be aware that
this class is not guaranteed to work the same from version to version,
or even that it will still be there in the next version of java, or even that
it may do something completely other than what it does now in the next
version. Read the sun.* class declaimer in the API docs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well to split one line into an array it would go like this

my @line = split(/\s*,\s*/, $inputLine);

to read an entire file this way it would be as so:

open(FH, ......);
while(<FH>) {
  my @line = split(/\s*,\s*/, $_);
  ..... work on this line ....
}
close(FH);

this is of course not doing any kind of error handling whatsoever, but
this should get you started.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There is no system variable for this. You are going to have to start
from the java.home variable. simply check if there is a bin/javac
under the java.home, if not check if there is a bin/javac under the
directory one level up from the provided directory. If both attempts
fail, then you may have to think of something else. Maybe leave the
option open to run with -Djavac.path=.... on the command line or
configurable in either a properties file or system/user preferences.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

jdbc not jdcb in the url lines maybe?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

perform the commands you think might be needed manually on the
command line. Once you have a sequence that works, throw them into
a file and your script is done (except maybe for a little fine tuning).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Have you tried any of the suggestions given yet?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

In your while (rs.next( ) ) loop, you are recreating "p" everytime.
So, only the last line is available. You would need to use some sort of
Collection (ArrayList probably) to be able to store all the records, but
then, you would also have to figure out a way determine which record
you wish to return the data for. Also, your jsp is currently only set up
to show one record as well. Building the table you want is going take
a bit more planning. Look into JSTL loops and, probably, a more
direct database query.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try adding the following to the policy file:

grant {
    permission java.lang.RuntimePermission
       "accessClassInPackage.sun.jdbc.odbc";
    permission java.util.PropertyPermission
       "file.encoding", "read";
  };

the policy file is located under JRE_HOME lib/security

or tomcat may have its own, you will have to search for
a file with poilcy in the name under the tomcat base
directory

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Shouldn't be a problem. Just remember that the xterm will close as soon
as the script finishes without leaving any delay to read messages so you
may wish to add

>somefile 2>&1

directly before the & at the end of the command.
This will capture the output (with errors) into "somefile".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay try the following sample of code. It will ask the user to enter
the file name, then open an xterm with a vi of the file then continue
with the script without waiting for the user to close the file again. If you
wish the script to wait until the user closes the file remove the "&" from
the xterm line.

echo "Enter filename:"
read file bogus
xterm -e vi $file &
masijade 1,351 Industrious Poster Team Colleague Featured Poster

System.out.println("Your Received message is as following:");
while((recv_Message=buff2.readLine() )!=null){
System.out.println(recv_Message);
}

four_characters=recv_Message.substring(recv_Message.length() - 4);
Four_characters_Integers = Integer.parseInt(four_characters);

I haven't tried it, I would, however, assume that recv_Message is null
at the point where you try to get the last four characters, as your
while loop will not exit until it is. Try this:

String last = "";
System.out.println("Your Received message is as following:");
while((recv_Message=buff2.readLine() )!=null){
  last = recv_Message;
  System.out.println(recv_Message);
}

four_characters=last.substring(last.length() - 4);
Four_characters_Integers = Integer.parseInt(four_characters);
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Sorry, I was away.

Well, what I am saying goes as follows:

the long running process should be contained in its own object rather than
being called directly from the jsp. Also, creating an instance of this
object should not start the process, but just create a "handle" to it. This
object should have "start", "stop", and "checkProgress" methods. The
start method should start the long running process in a thread. The stop
method should interupt this thread and perform and needed cleanup. The
checkProgress method should report back how far the process has
progressed (how you do/report/track this is completely up to you).

Now on to usage:

In initial JSP:
- create instance
- store instance as session object
- call instance start routine
- return an html page containing a "stop" link (url to "stop" page")
- this page will (after a set time) refresh to the "checkProgress" page
use the refresh header info for this

In refresh jsp:
- retrieve instance from session
- call the checkProgress method
- return an html page that will refresh to itself after a set time
use the refresh header info for this
- this page should also contain the "stop" link (url to the "stop" page)

In Stop page:
- retrieve instance from session
- call "stop" method
- delete the session object

masijade 1,351 Industrious Poster Team Colleague Featured Poster

jdbc is the Java DataBase Connector

odbc is the Ole DataBase Connector

two different products. There is a jdbc driver for java meant to give
access to sources that define an odbc "interface" which is then the
jdbc driver for odbc.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm ...

Look at your UpdateBean code. All of your get/set routines do
nothing but call themselves. They should actually return/set something
from the actual Bean, not just simply call themselves.

When all they do is call themselves, you have a classic case of infinite
recursion.

I assume you meant to call routines of the same name from the p
instance. If this is the case, you forgot to put "p." in front of the
subroutine calls inside of your set/get routines.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The performance between c and perl is minimal. If you use the "use" keyword, instead of the
"require" keyword, then the only real preformance difference will be in start up, as the entire
program will be read and interpreted before actual execution starts. Once execution starts,
then the performance is very much comparable to performance from c. And, considering you
do not have much time, and as long as the script will be running on a machine with a fairly
quick processor (so the start time will not be much of an issue) then perl is definately the way
to go.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just to be a bother, why does he need it in csh? Every UNIX system comes with a sh, or at
least sh compatable shell called sh. Unless you wrote your script using bash masquerading as
sh and he only has a true bourne shell, in which case many of your constructs will not work. I
would say to make sure that your script uses only true sh conventions and that the
#!/bin/sh
line appears at the top. That is the only other problem, because when that line does not exist the
script will execute using the users shell, which seems to be csh, but when it does exist, it will
operate in a "subshell" using sh.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Your JOptionPane is returning a String not an int. Capture your JOptionOutput in a String
variable then do input1 = Integer.parseInt(String var)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No problem. glad to be of help. Good luck with any future endeavers.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I don't think you can. I believe it is built into the Korn shell, not the OS.

You may want try multiple arrays and an indexing array. If you are not sure what I mean,
then I am sorry. It is a little complicated to explain in a forum such as this.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It looks okay to me. I can't see the rest of the program around it so I will go off on a limb
and say that maybe $Z should be variable here (at least if you have done it in the same way
as the earlier snippet of code). Also, as a debug option I can only say to try doing the
following directly before the if statement:

echo "===${Y}==="

the equals signs on both sides will let you see if the variable contains any thing other than
RUNNING. Maybe a couple of spaces or something, I don't know.

But in any case the construct is good.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Try replacing the following:

server_count=3 
server1=Mged 
serevr2=Mged1 
server3=myserver
.....
i=1 
while (( i<= $server_count )); 
do 
eval val=server$i 
val1=eval echo $$val 
.....
echo "$serveri is not running" | mailx -s "" [email]jselvaraj@gmail.com[/email] 
.....

with this:

set -A server Mged Mged1 myserver
.....
i=0
while (( i < ${#server[*]} ));
do
  val1=${server[$i]}
.....
  echo "$val1 is not running" | mailx -s "" jselvaraj@gmail.com
.....

the set -A creates a korn shell array. The first argument is the array name
with all additional arguments the values. The array index begins with 0.

This code can also easily be expanded by simply adding additional values to the
set -A line.

the construct ${#arrayname[*]} will return the number of items in the array,
which will be one greater than the last index (index starts with 0).

the construct ${arrayname[index]} will return the value stored at that index.

$arrayname or ${arrayname} or ${arrayname[*]} will return a space seperated
list of all items stored in the array (i.e. Mged Mged1 myserver) the will make the
use of the server_count and val variables needless. Hope this helps.

You can also assign to an array in the following manner:
arrayname[index]=value

You can also do this to increase an array by simply using an index one
greater that the last one which can be done without first checking the
current length with this convoluted construct:
arrayname[${#arrayname[*]}]=value

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Post the snippet of code using this, please. So that I can make a suggestion on a
method/fix that will work for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Are you using jdk 1.5 or an earlier version. If you are not using 1.5 then the following lines
must be changed:

for (String val : vals) {
    pStmt.setString(1, val);
    pStmt.execute();

to:

for (int i = 0; i < vals.length; i++) {
    pStmt.setString(1, vals[i]);
    pStmt.execute();
masijade 1,351 Industrious Poster Team Colleague Featured Poster

No What I meant was using the JDBC prepared statement. here an example:

String[] vals = request.getParameterValues("checkbox");
try {
  PreparedStatement pStmt = conn.prepareStatement("Insert into table (field) values (?)");
  for (String val : vals) {
    pStmt.setString(1, val);
    pStmt.execute();
  }
} catch .....

of course replacing checkbox, table, and field with the real things.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

With a prepared statement and multiple executes.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There are third party compilers you can get to do this, but that completely defeats the
purpose of doing something in Java, because the end compiled programs are once again
platform dependent.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If there will always be only one "." as in filename.txt then given
var=filename.txt
you can do
var2=`echo $var | awk -F'.' '{print $1}'`

if there is any possibility that the filename will have more than one "." as in filename.date.txt
then given
var=filename.date.txt
you can do
var2=`echo $var | sed -e 's/\.[^\.]*$//'`
this will return filename.date

masijade 1,351 Industrious Poster Team Colleague Featured Poster

like this?

server1=bogus
val=server$i
eval echo \$$val

masijade 1,351 Industrious Poster Team Colleague Featured Poster

as long as you have X11Forwarding set to yes on both the server and the client yes, you can
use xterm. For the server you must change sshd_config and restart. For the client you can
simply use -X (large x) on the command line.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

try this

if (Math.abs(number / 10) < 1000) {
  error message
}

since a five digit number will be at least 10000 or -10000

probably a little quicker than converting to string and evaluating
its length as well.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
^[A-Za-z -']*$
masijade 1,351 Industrious Poster Team Colleague Featured Poster

try this in a script:

while /usr/bin/true
do
xterm -e tail -f logfile
sleep 3600
done

this will open the tail in an xterm, wait exactly one hour (or close enough anyway)
and then open another (the logfile should have changed)

you probably will want to start this approximately one minute after a rotation has
occurred for the best effect.