amit sanghai

Ranch Hand
+ Follow
since Dec 05, 2000
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 amit sanghai

Hi,

I have Tomcat 5.5.1. I want to run a servlet when the server starts. How do I do that?

I tried using <load-on-startup>1</load-on-startup> but it did not work.

Please help.

Thanks and regards,
Amit Sanghai.
16 years ago
Hi,

I am using Javascript to transform xml using xsl. I am passing a parameter to the xsl from javascript.

Here is the script:

var xslname = "L401_View.xsl" ;
var xslt;
var xslDoc;
var xmlDoc;
var action = "Annuity" ;

xslt = new ActiveXObject("Msxml2.XSLTemplate.3.0") ;

xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");

xslDoc.async = false;
xslDoc.load(xslname);
if (xslDoc.parseError.errorCode != 0)
{
var myErr = xslDoc.parseError;
alert ("You have error " + myErr.reason);
}
else
{
xslt.stylesheet = xslDoc ;
xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0") ;
xmlDoc.async = false ;
xmlDoc.load('<%=xml.toString(responseXML).replaceAll("\\s\\s+|\\n|\\r", "")%>') ;
if (xmlDoc.parseError.errorCode != 0)
{
var myErr = xmlDoc.parseError ;
alert ("You have error " + myErr.reason) ;
}
}

xslProc = xslt.createProcessor() ;
xslProc.input = xmlDoc ;
xslProc.addParameter("insuranceProduct", action) ;
xslProc.transform() ;
document.write(xslProc.output) ;

Here, responseXML is the xml generated by the jsp which has this script.
I am getting an error: "Access is denied" at the line:
xslt.stylesheet = xslDoc ;

There is no error while parsing the XSL. Can anybody tell me why am I getting this error?

Thanks and regards,
Amit Sanghai.
I got the answer. I have to dealy the calling of the onChange event handler by writing an anonymous function and calling it on onchange.

var select = document.createElement("select") ;
var functionArguments = xmlNode.getAttribute("functionArguments") ;
var functionText = xmlNode.getAttribute("onChangeFunctionText") ;

select.onchange = new Function(functionArguments, functionText) ;


Thanks.
I need to create the code on the fly. This is the need of the project. I am getting all the drop down picklist data from xml and on change of its value I need to call other dependant picklists which are hidden at first but become visible later. So the javascript code is also dependant on the drop downs.
Thanks, but I want to add the function at runtime using DOM not directly as static code.

var script = document.createElement("script") ;
script.setAttribute("language", "javascript") ;
script.appendChild(document.createTextNode(function)) ;
Hi,

I am trying to append a <script> tag to a div at runtime. The script has a function. But I am getting the following error on IE:

Unexpected call to method or property access.

It works in Firefox. Can anyone please help me.

var script = document.createElement("script") ;
script.setAttribute("language", "javascript") ;

var functionText = "function test(){alert('hello')}" ;
script.appendChild(document.createTextNode(functionText)) ; // this statement gives the error.


Thanks and regards,
AmIt Sanghai.
hi,

I used the following code:

protected void doPost( final HttpServletRequest request
, final HttpServletResponse response ) throws ServletException, IOException
{
InitialContext context = getInitialContext() ;

try
{
System.out.println("context : " + context.toString()) ;

// Get a reference to the Bean
Object reference = context.lookup("HELLOEJB") ;
System.out.println("object reference : " + reference.toString());

// Get a reference from this to the Bean's Home interface
HelloHome home = (HelloHome) PortableRemoteObject.narrow (reference, HelloHome.class);

System.out.println("home interface : " + home.toString());

// Create the EJBObject from the Home interface
HelloRemote hello = home.create();
System.out.println("remote interface : " + hello.toString());

// Get the result
String result = hello.helloWorld() ;
response.setContentType("text/html") ;
PrintWriter out = response.getWriter() ;
out.println("Output from HelloEJB : " + result) ;
}
catch(Exception e)
{
e.printStackTrace() ;
}
}

private InitialContext getInitialContext()
{
Hashtable props = null ;
InitialContext context = null ;
try
{
props = new Hashtable();

// For OC4J SERVER
props.put(Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory");
props.put(Context.PROVIDER_URL, "ormi://172.16.88.49:8888/Testhello") ;
context = new InitialContext(props) ;
}
catch(Exception e)
{
e.printStackTrace() ;
}
return context ;
}


The client servlet is at my machine on Tomcat. The ejb is at some other machine on OC4J. Using the above code there is no error but the ejb is not reached... It hangs, waiting for the ejb. The two machines are on a normal intranet.

Thanks and regards,
Amit.
I used the following code:

protected void doPost( final HttpServletRequest request
, final HttpServletResponse response ) throws ServletException, IOException
{
InitialContext context = getInitialContext() ;

try
{
System.out.println("context : " + context.toString()) ;

// Get a reference to the Bean
Object reference = context.lookup("HELLOEJB") ;
System.out.println("object reference : " + reference.toString());

// Get a reference from this to the Bean's Home interface
HelloHome home = (HelloHome) PortableRemoteObject.narrow (reference, HelloHome.class);

System.out.println("home interface : " + home.toString());

// Create the EJBObject from the Home interface
HelloRemote hello = home.create();
System.out.println("remote interface : " + hello.toString());

// Get the result
String result = hello.helloWorld() ;
response.setContentType("text/html") ;
PrintWriter out = response.getWriter() ;
out.println("Output from HelloEJB : " + result) ;
}
catch(Exception e)
{
e.printStackTrace() ;
}
}

private InitialContext getInitialContext()
{
Hashtable props = null ;
InitialContext context = null ;
try
{
props = new Hashtable();

// For OC4J SERVER
props.put(Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory");
props.put(Context.PROVIDER_URL, "ormi://172.16.88.49:8888/Testhello") ;
context = new InitialContext(props) ;
}
catch(Exception e)
{
e.printStackTrace() ;
}
return context ;
}


The client servlet is at my machine on Tomcat. The ejb is at some other machine on OC4J. Using the above code there is no error but the ejb is not reached... It hangs, waiting for the ejb. The two machines are on a normal intranet.

Thanks and regards,
Amit.
I tried that but it did not work. What should be the Provider url and the initial naming factory class?
I tried that but it did not work. What should be the Provider url and the initial naming factory class?
Hi,

There is an EJB running on an OC4J server. I have a servlet runnning on tomcat on a different machine. The servlet wants to call the EJB. How can it do that?

Thanks and regards,
Amit Sanghai.
Hi,

I have lots of objects that I want to cache just when the tomcat starts up. How can I do that?

Thanks ans regards,
Amit Sanghai.
16 years ago
Hi,

I have a form with certain number of input fields, but the form is not hard coded jsp, it is in XSL. The values entered by the user in the input fields are taken and a XML file is made. I want to input validation of all the fields at once with all the error messages returned back with the specific elements. How can I do that? This is not possible with XSD because it returns only one error at a time.

Thanks and regards,
Amit Sanghai.
The problem with validation using XSDBuilder is that when there is error in one element, it throws exception. It does not validate the XSML as a whole.