milil 24 Newbie Poster

Code is always the same because Java take care of backward compatibility.
Here you have tutorial about connection to database.
They explain every line of code what is made for.
Read that and I think you will not have any problems in future.
Kind regards, Mike.

milil 24 Newbie Poster

First you will need to create workflow, so starting from first question to the end.
When you create that you will see if you have a lot of branches for one question or not.
If yes you can do it in few ways:
- Store values in session then check is session value USA then start new branch of questions.
- And to store questions in MySql

I think second solution is better because of this:

If you use sessions:
If your user in the middle of questions goes out turn of his browser you will end up with nothing.
If you want to wait user finish everything then store it in db that wouldn't happen.
What is good thing about Session is that you store in DB just once so your server will be faster.
That describes problem for continually storing in DB you will make your server slower.
But even it will be slower you will have some data in DB if user leave it...

Both of this approach have good things and bad, I will use MySql because nowdays servers have good speeds so it will not affect your website that much.
For implementing I suggest JavaScript and JQuery...

milil 24 Newbie Poster

What I do to create reports from database is iReport.
You can draw what kind of report you want, then convert that to jasper report.
When you have it done it is just sending list of values to that report and he will know how to hande it.
So you will have something like this.
Press button to generate report let say monthly sales.
Your servlet is called, he goes in database grab all values that he need.
Send that values to this compiled jasper report.
And you specify how would that report look like. I always put PDF.
Then after clicking on button user will get pdf opened with values you need.
I don't know what kind of report you need I never work with that kind of taglbis, if you want I can show you my code how it generates PDF with jasper reports.

milil 24 Newbie Poster

Answer is NO! Tag lib is just to use functions of java in jsp page, why to use library in servlet when you have java core functions already there.
Can you give me example when would you use that in servlets?

milil 24 Newbie Poster

If I understand you right you need Date Picker?
You can see one on this link you have there already source code.

milil 24 Newbie Poster

This will return all dates that your propertie had people in it.
So you can do it like this:
Make a metod that will get input parameters fromDate and endDate.
You grab from database every dates you have.
Than use a for or while loop to go over all data you get.
Use a fromDate and see is it smaller then MoveIn date in frst row:
if yes then calculate how many days you have fromDate to MoveIn because it was empty
if not then use a MoveOut and save it to field with one flag

then use a second row and if flag for MoveOut is UP then you calculate how many days has passed from Move Out from first row to MoveIn from second and add it to sum off all days,
then use that for all rest rows if it satisfy condition that is endDate bigger then MoveIn or MoveOut.

If you have problems to understand what I mean with this. Ask me on PM to explain you better, but this can be one algorithm...

Regards, Mike.

milil 24 Newbie Poster

I had a same problem but i need a minutes, so you get a new time then subtract 1 hour or in my case 10 minutes from it and then you ask is that time greater then that time in database if it is you do what you want to do if not they your result from SQL will be nothing and that is it...
Code:

$newTime = date("Y-m-d H:i:s");

$timeLess10m = date("Y-m-d H:i:s", strtotime('-10 minutes', strtotime($newTime)));

$SQL="SELECT * FROM `DB` WHERE `ID` = 1 AND `TIME` < '" . $timeLess10m ."'";

$rez = mysql_query($SQL) or die("Error: ".mysql_error());
$num_rows = mysql_num_rows($rez);
if ($num_rows > 0) {
    // 10 minutes is passed
} else {
    // we are still in 10 minutes period...
}

I hope this would help, Mike.

milil 24 Newbie Poster

I think you need to subtract hours from main sum, then subtract minutes from the main sum and you will have secounds you need.
For examples you have 8000 secounds when you divede that with 60 to get minutes so you have 133.3 so now you need to divide that with 60 to get hours. Sou you get 2 hours.
You now calculate it like this 8000 - 7200 (2h represented in secounds) = so you have rest of 800 secounds. Now again divide it by 60 to get minutes you get 13.3 minutes now you use 13 minutes * 60 secounds you have 780 secounds sou you allready have 2 hours, 13 minutes and secounds you get by subrtacting 800 - 780 and you have 20 secounds...
You need to implement something like that. I wanted first to make you try to do that, if you again have trouble with code i will help you with coding...
Mike.

milil 24 Newbie Poster

You need to use SwingWorker. He is used for progres bars i think you can redesign it, so you can show message you want in seperate thread so your method will run free.

I used that to download picture from internet and in progres bar I will show how much proces is done. So your method will download everything you need and other will show message.

milil 24 Newbie Poster
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

did you add that line of code in your jsp page?

shwetha.marigowda commented: ya i have added that in starting itself, tag lib +0
milil 24 Newbie Poster

Length is number of values in array called args.

milil 24 Newbie Poster

I think that you can do all that with team viewer and a program that will activate on startup, you can set your program to reactivate your connections and start team viewer program again...

milil 24 Newbie Poster

Hmm add semicolon at the end of the sql querry:

$qry = "select project from PROJECTS_PROJECT where project='ab1234';";

If that don't work hmm enter same sql in phpmyadmin so if it works you have problem with code, secound it can be mysqli problem I think that in older versions of PHP there is a cases when it won't work...

milil 24 Newbie Poster

You can write something like this:

<form method=post action="page.php" id='my_form'>
<input type="hidden" id="userName" name="userName" value="login_id" >
<input type="hidden" id="password" name="password" value="some_password" >
</form>
  <script>
    document.getElementById("my_form").submit()
  </script>

This will make form with some input fields and then call submit so it will redirect to another page. If you want to send some data with that form you can do it like this:

<input type="hidden" id="username" name="username" value="<?php echo $_POST['username']; ?>" >

so you will have text filed filled with value from your previous POST and then that value will be send to another page...

milil 24 Newbie Poster

You can't have method in method.
method1() and method2() are in public static void main() so compailer is complaining...
put method1 and method2 outside public static void main and it will be ok.

milil 24 Newbie Poster

Start with w3schools they offer great tutorial for beginers. For every "step" you have example how to do that so that is starting point. If you want that your new page look like previus you need CSS template just insert few lines of codes and that is it.
I will start with funcionality how to insert into database and when you finish it then work on how site will look. If you have more questions feel free to ask...

milil 24 Newbie Poster

If you want to learn best way is on w3schools.com. You have examples and tutorials how to do form with post or get methods and so much more. I think that you will learn faster if you go over that examples, and if you still have questions post a new question and we will help you.

milil 24 Newbie Poster

Hmm you don't need to worry about that because Java will, you can set it to import * but when you want to create .jar file Java will deploy classes that you need not all of them...
if you wan't to test it you can try it with * and when you import single files with this code:

long start = System.nanoTime();

// code to test

long total = System.nanoTime() - start;
System.out.println("Time needed for sorting: " + (total / 1000000.0));

And if difference is huge please tell us, I didn't test it but my profesor say that you can do it with star...

milil 24 Newbie Poster

Problem is because you do this: num1 = null; num2 = null; and you are calculating average with two null's you can't do that.

You need to do like this:

    import java.lang.Math;
    import java.util.Scanner;
    public class PairTest
    {
    private static double num1;
    private static double num2;
    private static double average;
    private static double distance;
    private static double maximum;
    private static double minimum;
    private static Scanner in;
    public static void main(String args[])
    {
    in = new Scanner(System.in);
    System.out.println("Please enter a value for the first number: ");
    num1 = in.nextDouble();
    System.out.println("Please enter a value for the second number: ");
    num2 = in.nextDouble();

    average = (num1+num2)/2.0;
    distance = Math.abs(num1-num2);
    maximum = Math.max(num1, num2);
    minimum = Math.min(num1, num2);

    System.out.println("Average: " + average);
    System.out.println("Distance: " + distance);
    System.out.println("Maximum Number: " + maximum);
    System.out.println("Minimum Number: " + minimum);
    }
    }
    }

So you declare average as double and you can't know num 1 and num2 so you need to read values from scaner and then calculate it when you get num1 and num2...

milil 24 Newbie Poster

You just go on your program you want to build as .jar.
Go File>Export>Runnable Jar and then you have options how to pack it...
Find what you want and it will automaticly include jdbc.driver in your .jar package...

milil 24 Newbie Poster

Hmm, no, answer is correct. You can watch that as Folders in MyComputer,
You have C:\ then you have User\ then you have Smile\ then you have Movies\ so your path is C:\User\Smile\Movies\ and you see content on disk in that folder in Java is the same way, he goes throuh structure of your package and find last one, then he search for file you asked...

milil 24 Newbie Poster

You can do it in try block:

try { } catch (Exception e) { e.printStackTrace(); }

Or you can add on method throws IOException or what exception you need to catch...
You can write your own exceptions lik this:

class YourException extends Exception {
    YourException() {
        super("You can write your own message...!");
    }
}