Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!

Amy Medrat

+ Follow
since Mar 05, 2006
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Amy Medrat

Use masking to verify the phone number rather than cheking the integer, sample below.

<field property="phone"
depends="maxlength, mask">

<arg1 name="maxlength" key="${var:maxlength}" />
13 years ago
Dear Ranchers, Can you please suggest me wich one out of Induslogic and Xansa is better if salary is left aside.
14 years ago
Which book is the best for struts? I have short listed following three. But need help as to which would be the best to buy.

1. The Complete Reference by James Holmes
2. Struts In Action - Manning
3. Programming Jakarta Struts � Oreilly

14 years ago
Thanks very much Brent and Merrill.
15 years ago
Hi All, Need some help.

I want to get the real path of a file and then using this path perform some operation within the action class.
In servlets we used to have servletcontext.getrealpath("file name"),
but within the ActionClass.execute() method how can i get the same information.

[ March 22, 2006: Message edited by: Amy Medrat ]
15 years ago
I think you can resolve this by seting the validation false.

SAXParserFactoryObject.setValidating(false) // if you are using SAX parser
DocumentBuilderFactoryObject.setValidating(false) //if using DOM parser

Hope this helps.
[ March 17, 2006: Message edited by: Amy Medrat ]
Here is the code... Enjoy!


package java_practice.saxpractice;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.w3c.dom.*;

// For write operation
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.dom.DOMSource;


public class TransformationApp02
// Global values
static Document documentA;
static Document documentB;

public static void main (String argv [])

//Directory path where the files are located.
String directorypath = argv[0];

String aXml = directorypath+"A.xml";
String bXml = directorypath+"B.xml";

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

try {
File fA = new File(aXml);
File fB = new File(bXml);

DocumentBuilder builder = factory.newDocumentBuilder();
documentA = builder.parse(fA);
documentB = builder.parse(fB);

NodeList nodeListA = documentA.getElementsByTagName("B");
for(int count=0 ; count<nodeListA.getLength();count++)
Node nodeA = nodeListA.item(count);
Node temp = documentB.importNode(nodeA,true);
Element element = documentB.getDocumentElement();

// Use a Transformer for output
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();

DOMSource source = new DOMSource(documentB);
StreamResult result = new StreamResult(bXml);

transformer.transform(source, result);

} catch (TransformerConfigurationException tce) {
// Error generated by the parser
System.out.println ("\n** Transformer Factory error");
System.out.println(" " + tce.getMessage() );

// Use the contained exception, if any
Throwable x = tce;
if (tce.getException() != null)
x = tce.getException();

} catch (TransformerException te) {
// Error generated by the parser
System.out.println ("\n** Transformation error");
System.out.println(" " + te.getMessage() );

// Use the contained exception, if any
Throwable x = te;
if (te.getException() != null)
x = te.getException();

} catch (SAXException sxe) {
// Error generated by this application
// (or a parser-initialization error)
Exception x = sxe;
if (sxe.getException() != null)
x = sxe.getException();

} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built

} catch (IOException ioe) {
// I/O error



[ March 17, 2006: Message edited by: Amy Medrat ]
While using connection pooling, what all care the java application should take if there is a database connectivity problem/database crash/database reboots?
Such that when the database restarts the application resumes the functionality automatically.
this means the current object.

lets take the example below

class TestThis

int intVal;

public void callMe(int intVal)
this.intVal = intVal;

public static void main(String args[])
TestThis obj1 = new TestThis();



here in the example callMe(int) function has a local variable with name intVal wich is also present in the class as an instance variable.
now if i want to initialize the the instance variable the expression intVal = intVal; wont work i have to specifically tell the object. This can be done using the key word this.
So when we say this. it reffers to the the current object on which this function has been called, and we can use to to refer to the instance variable.

Also note that you cannot use the keyword this in a static function, lets say if you write "this.inVal = 1;" in main method, the code wont compile as you cannot use this in a static method.

Hope you are not more clear on "this" concept.
You can try HashMap

HashMap customerQue = new HashMap();
for( int i = 0; i < 5; i++ )
customerQue.put(""+i,new Customer());
15 years ago
Dear faisal,

First thing that you should understand, you cannot assign a null to a primitive data type, i.e. if I say
boolean bolVal = null;
int intVal = null;

is illegal.

A null value can be assigned to only object type.

So when you call �new Confusing(null);�

It searches for the constructor which have Object type in the parameter.

In the code above we only have two best fitted constructor here

1.private Confusing(Object o)
2. private Confusing(boolean Array[])

now out of these two private Confusing(boolean Array[]) is selected because Object is the super class of the Array object and it is the first to be best fitted.

Now if you change private Confusing(boolean Array[]) to private Confusing(boolean Array) it again becomes a primitive value so a null value cannot fit in this so after this change you get a out put as �Object�..�

Now lets say I add another constructor to the code you have above :
private Confusing(String o) {

the moment you also add this constructor to this you wont be able to compile the code as the it creates an ambiguity in which you cannot decide as to which constructor is best fitted Confusing(String o) OR Confusing(boolean Array[])

hope this has helped you in understanding the concept.
[ March 08, 2006: Message edited by: Amy Medrat ]
15 years ago
Probably it depends on how you would be accessing the data..

1. If you want to access the data with the help of a key lets say the index value here you can put the index as key and the rest values clubbed in a object as a value object in either HashMap or HashTable.
The difference between HashMap and HashTable is that HashTable is synchronized where as HashMap is not.

2. If you do not think you would be accessing the data by key you can put it in an Arraylist as Satou mentioned above.
15 years ago
Hey Ali, I hope this would help

select * from tableName
where rowid in (select rowid from tableName where rownum < 21
select rowid from tableName where rownum< 11)
Hey Aafreen, The phrase "On the fly" indicates that you can create new extended classes without writing the whole syntax for class creation.

See below an example,
I have created an instance of the interface(Interface1) without creating any new class.
This is what it means, �Anonymous classes are created on the fly�

Hope this helps.

interface Interface1
public void callMe();

class Example
public static void main ( String args [ ] )
new Interface1()
public void callMe()
15 years ago