tarun saha

Greenhorn
+ Follow
since Mar 23, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by tarun saha

vjy chin wrote:Ben,
thanks for the reply. Actually I found a solution which will work for me, though I couldnt find a way to open a pop up from a servlet.

The response from the servlet comes to the jsp page and in the jsp page I am using onLoad method in the body tag. The onLoad method checks for a particular string. If the string is equal to the value I am checking, the pop up window opens.

If anyone wants still mroe details, I would be happy to provide.

Thanks



Hi ben,
I have a same requirement as yours but slightly different. I have to get to the popup and back to same action class to fulfill the steps.

So its like:
1. Display the jsp.
2. On submit go to processAction.
3. fetch required details.
4. forward to a popup.
5. get data from popup.
6. update the db from processAction.

So I have to make two transits from the UI to server and back twice.

Any Idea how I can perform that?

Thanks in advance.
13 years ago
No actually i figured it out.
The impl class should not have static methods.
Then the service builder wont create the util class.
It will throw this warning.
13 years ago
Since the last post was incomplete and that it did not help, I am restarting this problem statement.

How to set build.sysclasspath.

Moreover when I build-service for the second time, the service files are no longer generated.

It shows this error that build.sysclasspath should be set to false for repeatable builds.
13 years ago
Hi every body,

I wanna store the remainders of numbers.

So the quotient could be of any length, say long int.

Now i just wanna get the byte 0/1.
so how can i achieve that?
Boxing? Parsing? Casting?
please do reply.

i want something like:

remainder<byte type> = quotient<pretty long> % 2;

currently i am using temporary string like:

tempRemainder = quotient%2; // integer

tempRemainderStr = String.valueOf(tempRemainder); // string

tempBinArray[index]= Byte.parseByte(tempRemainderStr); // byte


But i don't think it is efficient to use immutable string.

please do help.

thanks in advance.
13 years ago
Shanky, that is exactly what our point is (and not an disadvantage).

We use parent reference when we don't want to use the subclass methods or attributes.
We rather use it for a generic parent class level.
So in this way java prevents this newly created "parent-referred-object" to access the subclass fields.
This is a protection and not a disadvantage.

Am I able to clear your doubt?
13 years ago
Yup we are on the same page now
13 years ago
Marco thanks again.

So like my doubts are clear. We use the parent/same reference when we need to put it at the hierarchical level of the parent/same class.

Usage of parent reference helps in hiding the extra implementation defined in its subclasses.
13 years ago
Thanks a lot to both of you.

This is when it is an inerface where the implementation details is with the implementer.

But lets consider two classes Parent and Child. where the Child overrides a certain method as well as defines a couple of new methods.

How will then we implement this concept of Parent Reference and the importance of it?
13 years ago
What is the difference these two lines.

List listObject = new ArrayList(); // Parent reference and child instance
ArrayList arrayList = new ArrayList(); // Direct same class reference

What is reason to use the first line.
I have used both but could not spot a difference.

Instead if I use the first line in other such examples of polymorphism, I am not able to use the new functionality of the child class(unless downcasted).

So my main question is why do we use the "Parent Reference" at all?
Just to main it generic from that hierarchy of inheritence? so that it can be applicable for all other subclasses of it?
13 years ago
ok guys, now i got it.

since finally is there in the jvm stack, it has to be executed anyway unless i shut down jvm using System.exit();

but the main thing is that once the redirection takes place the request response cycle will be different and the old request/ response will not be available.
13 years ago
hey from two different replies i am confused.

So the answer is no right? I am convinced that the req, res cycle is different in sendRedirect and dispatcher.forwardTo.

if the
[code:] sysout("I am in caller servlet A");
redirection code;
sysout("I am back in A");
[:code]


The second line "I am back in A" will work only in case of dispatcher and not redirect.

Am I correct now?
13 years ago
Like in RequestDispatcher.forwardTo... Can we get back to the calling servlet after response.sendRedirect

So lets say ServletA is redirecting to ServletB, so after the redirection process and the ServletB does its job, can we return to ServletA?
13 years ago
well my question is how can i add the contains of the resultset into an arraylist in such a way that when i retrieve the arraylist they are all in object form.

So let me make in clear with the actual implementation.

my class is like:
public class DataBeans{
String id;
String name;

public setId()... assume
public setName()....
}

Now i have created its object and submitted in the database using jdbc. Works perfect.
I am also able to read this data in my database and it retrieving successfully

But i want to add this set of objects(the rows of the table) into Arraylist.

here is my code:


public fetch(){
DataBeans db = new DataBeans();
List<DataBeans> list = new ArrayList<DataBeans>();

ResultSet rs = smt.exe.... working...

while(rs.next()){
db.setId(rs.getString("id")); //printing distinctly for each record successfully
db.setName(rs.getString("name")); //printing distinctly for each record successfully

list.add(db); // this is updating the contents of a single index and every time i read the list, all objects' value becomes the value of the last entered object.
}
}

So my basic question is how may i add the objects in a list uniquely, mine is rather overwriting the existing contents

the my data set in database is:

id name
A_1 A1
A_2 A2

but when i retrieve it the content of the list:

id name
A_2 A2
A_2 A2


please help
thanks for any help in advance.

Rob Prime wrote:Change into That's not that hard, is it?



Thanks worked.
But i couldn't understand how..
13 years ago
hey guys, i found a strange java behavior

we all know how to create a file reference, an actual file and directory, renaming it and so on. but the renameTo returns a boolean.
now i will show you a problem where an earlier referenced directory is recreated

[code:]

File myDir = new File("New Directory") //created a reference and myDir is pointing to that reference
myDir.mkdir(); //actually created the directory named "New Directory"
//works great

myDir.renameTo(new File("My Dir")) // created a new file reference named "My Dir" and "New Directory" is changed to "My Dir"
// works great again
// BUT TRAGICALLY myDir IS NOT POINTING TO THE NEW REFERENCE
// myDir is still referring to "New Directory"

So till now I created a directory named "New Directory", renamed it to "My Dir" and i find a "My Dir" on my desktop...........cool.
It all works great till now, superb, but the moment i create a sub directory in "My Dir"- Formerly "New Directory", i am able to do that easily.

BUT IT CREATES THE OLD DIRECTORY AGAIN

so i continue the above code:

myDir = new File("My Dir/Inside Dir"); // This line creates the old directory "New Directory" in the desktop
myDir.mkdirs(); // This line actually creates the nested directory.


(After the file runs successfully) Now i have two directories on the desktop 1. My Dir and 2. New Directory. And inside My Dir i have another directory "Inside Dir".
But the New Directory is HAZARDOUS. It is basically because even though i have renamed the directory, the file object-myDir still is not referring to it. Remember the difference between x=x.concat("world") and x.concat("world")? in second case it does the job but it is lost in the very next moment while in the first case it is assigned to the reference variable/ object x.

So what i meant with the above code is that while calling the constructor File at the last-but-one line, it is creating another directory with the old name(Note this is happening before saying mkdirs()). Now it should not even create the directory before mkdir() is used, but in this case it is created the moment i call the file constructor - The FIRST PROBLEM.

SECOND PROBLEM- I am writing a code where i have to dynamically generate temporary folders and rename them accordingly, then i am forced to reuse the file object. So if every time it creates a new directory in huge directory structure, everybody is going to shoot me down.

Please solve this if you can.

Thanks for any help in advance.

Regards.
13 years ago