Sumon Mukherjee

Greenhorn
+ Follow
since Dec 19, 2007
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 Sumon Mukherjee

Tried getURL(), getRequestURL(),getQueryString(), getPathInfo(), but no luck...
11 years ago
JSP
I need the jsp equivalent of Request.ServerVariables() in asp. Please advise...
11 years ago
JSP
Hi,

Greetings!

I have this method that accepts an empty Jdom document as an input argument. There is also a String variable which contains the XML stuff which I need to add to the Jdom document. For eg:
public static Document loadXML(Document jDoc, String strTags)
String will contain-
strTags = "<RequestBody><first>Sumon</first><last>M</last></RequestBody>";
I add this string to my Jdom document and my method returns the modified jdom document which can later be used for other functions.

The problem is i already have the content in my string variable and dont want to create a file in the phsical memory.

One way i can think of is to create a temporary file to wrap this string and delete it on exiting. But this approach has it own problems, say if there are 100's of users logged in and my temporary file has exclusive lock on it.....the waiting time will be too much n my users will prefer not to use my site!

Is there any other way i can wrap this string/convert to File object so that i can ue the temporary Jdom document from the memory.

Any help in this regard will be highly appreciated!

Thanks
Sumon
11 years ago
Thanks a lot Jesper.That helped.

I was also doing one more mistake. The project where my java program was had jdk 1.5 and my test project had jdk 1.4...so there was a mismatch also.

Thanks Again,
Sumon
11 years ago
Hello All,

Greetings!

I have created a project in Eclipse. In that I have created a package com.test.xml in which I have a java program xpathNode.java. I am using my java class to read and write into an XML file.The program is running fine and error-free.

Now I am trying to create a jar of the the class file, so that it can be used in other projects. I am creating the jar using the jar utility from the command prompt. I am going to the WEB-INF>classes>com>test>xml folder of my project and running the jar utility-

jar -cvf XMLnode.jar xpathNode.class

Now I am trying to use this jar in another project XMLEngine. I am putting the jar file XMLnode.jar in the lib directory as shown below.My new project has the following directory structure-
XMLEngine
|_ pages-my jsp page
|_ WEB-INF-it has the src,classes and lib folders

I have also put the XML related jar's like jdom.jar,xalan.jar etc in the lib dir. I have put my jar XMLnode.jar in the eclipse project classpath as well.
In my jsp page I have put reference to my class as-
<%@page language="java" import="com.test.xml.*,org.jdom.*....%>

I have deployed the project in Weblogic 8.1.

Now when I am trying to call one method of my java class from my jsp page it is throwing me errors saying-
java.lang.NoClassDefFoundError: com/test/xml/xpathNode

I created another project and it is giving me another error saying-
An error occurred at line: 2 in the jsp file: /pages/samplePage.jsp
Generated servlet error:
xpathNode cannot be resolved

Can someone help me out please.I think I am missing something very important.Any help in this regard will be highly appreciated.

Thanks in advance!

Best Regards,
Sumon
11 years ago
Thanks for the reply,

As you can see there is no authentification required so i added the following piece of code :
env.put(Context.SECURITY_AUTHENTICATION,"none");
still i get the same problem.

I am totally stuck .

If you can see my ldap query :
<LDAP://kworld.myserver.com:123/dc=uk,dc=kworld,dc=myserver,dc=com>;


So for this have set these values correctly :
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "LDAP://kworld.myserver.com:123");
DirContext ctx = new InitialDirContext(env);
String base = "dc=uk,dc=kworld,dc=kpmg,dc=com";

and i am searching as
NamingEnumeration answer = ctx.search(base, filter, ctls)

I dont see any authentification to be required here.

regards,
Sumon
11 years ago
Hi
I am using the following LDAP query to retrieve data from the Active Directory environment:
< LDAP://kworld.myserver.com:123/dc=uk,dc=kworld,dc=myserver,dc=com>;(&(ObjectCategory=person)(ObjectClass=user)(employeeID=*)(!(userAccountControl=514)));UserPrincipalName,CreateTimeStamp,GivenName,TelephoneNumber,HomePhone,Name,sn,Company,c,l,st,StreetAddress,distinguishedname;subtree

I am getting the error -
LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627- Get Active Directory RootDSE with JNDI

//-----------------------------------------------------------------------------------------//
// My Java code for the above is :
//-----------------------------------------------------------------------------------------//

import javax.naming.*;
import javax.naming.directory.*;
import java.util.*;

public class KPMGADSearch{

public static void main(String args[]) throws Exception{
dc.controlArrtibutesInResults();
}

/**
* This methos shows how to search and control arrtibutes returned in the result.
* Create search controls and allow java objects to be returned in the results.
*/
public void controlArrtibutesInResults() throws Exception{
DirContext ctx= getDirContext();

// Specify the ids of the attributes to return
String[] attrIDs = {"CreateTimeStamp" , "ModifyTimeStamp" , "GivenName" , "TelephoneNumber" , "HomePhone" , "Name" , "sn" , "Company" , "Title" ,"Mobile" , "c" , "l" , "st" , "Mail" , "EmployeeID" , "PostalCode" , "distinguishedname"};
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes (attrIDs);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String filter = "(&(ObjectCategory=person)(ObjectClass=user)(employeeID=*)(!(userAccountControl=514)))";
String base = "dc=uk,dc=kworld,dc=kpmg,dc=com";
NamingEnumeration answer = ctx.search(base, filter, ctls);
formatResults(answer);
ctx.close();
}

/*
* Generic method to format the NamingEnumeration returned from a search.
*/
public void formatResults(NamingEnumeration enumeration) throws Exception{
int count=0;
try {
while (enumeration.hasMore ()) {
SearchResult sr = (SearchResult)enumeration.next();
System.out.println("SEARCH RESULT:" + sr.getName());
formatAttributes(sr.getAttributes());
System.out.println("====================================================");
count++;
}

System.out.println("Search returned "+ count+ " results");
} catch (NamingException e) {
e.printStackTrace();
}
}

/*
* Generic method to format the Attributes .Displays all the multiple values of
* each Attribute in the Attributes
*/
public void formatAttributes(Attributes attrs) throws Exception{
if (attrs == null) {
System.out.println("This result has no attributes");
} else {
try {
for (NamingEnumeration enumeration = attrs.getAll(); enumeration.hasMore() {
Attribute attrib = (Attribute)enumeration.next();
System.out.println("ATTRIBUTE :" + attrib.getID());
for (NamingEnumeration e = attrib.getAll();e.hasMore()
System.out.println("\t\t = " + e.next());
}
} catch (NamingException e) {
e.printStackTrace();
}
}
}

/** Generic method to obtain a reference to a DirContext */
public DirContext getDirContext() throws Exception{
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory ");
env.put(Context.PROVIDER_URL, "LDAP://kworld.myserver.com:123");
// Create the initial context
DirContext ctx = new InitialDirContext(env);
return ctx;
}
}
//-----------------------------------------------------------------------------------------//

I am getting the following error :
javax.naming.NamingException: [LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece remaining name 'dc=uk,dc=kworld,dc=myserver,dc=com'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3028)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
at com.sun.jndi.ldap.LdapCtx.searchAux (LdapCtx.java:1811)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1734)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search (PartialCompositeDirContext.java:328)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
at com.hp.kpmg.ldap.KPMGADSearch.controlArrtibutesInResults(KPMGADSearch.java:118)
at com.hp.kpmg.ldap.KPMGADSearch.main(KPMGADSearch.java:44)
Exception in thread "main"

Can i get some help on this ,
No clue .

thanks in advance,

Sumon
11 years ago
William and Paul...thanks a lot for your replies.

I tried something like this -

My XML file looks like this-
<header>
<presentation role="category" label="Category">
Directory Services
</presentation>
</header>

I am trying to replace the text of this element.

This is my function -


public static String setAttrib(Document xmlDoc,String strTag,String strElement,String strAttr,String strAttrValue,String newVal)
{
String retu = null;
Node n = null;
Node fstNode = null;
Node childNode = null;
int c = 0;

xmlDoc.getDocumentElement().normalize();

NodeList nodeLst = xmlDoc.getElementsByTagName(strTag);

for (int s = 0; s < nodeLst.getLength(); s++) {
fstNode = nodeLst.item(s);
NodeList childNodeLst = fstNode.getChildNodes();
for (int p = 0; p < childNodeLst.getLength(); p++) {
childNode = childNodeLst.item(p);

if (childNode.getNodeName().equalsIgnoreCase(strElement)){
NamedNodeMap childAttr = childNode.getAttributes();
for ( int q = 0; q < childAttr.getLength(); q++){

if(childAttr.getNamedItem(strAttr).getTextContent().equals(strAttrValue)){
childNode.setTextContent(newVal);
break;
}
}
}

}
}
}

<<Sorry for pasting it in this format as all the indentations were getting jumbled>>

Document XMLDoc is a parsed XML doc.

Now my method is changing the value. But it is doing so in the memory.

Any idea how I can write it to the XML file? Should i use StringBuffer class or DOM. If so how?

Thanks for your help.

Cheers,
Sumon
11 years ago
Hello All,

Greetings!

I have deployed an application 'ThinApp' in Weblogic 8.1 SP5. I created a separate domain(port 7001) in WL where I deployed my application. My application uses the JNLP/WebStart to get updates whenever any new modifications are made to my application 'ThinApp'.

I have created a separate domain(port 7003) in Weblogic for JNLP.
I have deployed the web-app 'JNLPAPP' which contains the signed jars and workspace.xml in my JNLP domain. The workspace.xml present under my WEB-INF

<<<<<Dir structure of my JNLPAPP>>>>>
JNLPAPP
|-index.html> it has a link which launches the JWS.
|-WEB-INF
|-lib>signed jar's & a workspace.xml which decribes the entry point for my JNLP to the application 'ThinApp'.

My JNLPAPP web-app was successfully deployed. When I am trying to access my JNLP from IE with the link http://localhost:7003/JNLPAPP it is throwing a HTTP Error 403 Forbidden.

Any idea why? If you need any more information please let me know.

Thanks in advance,

Best Wishes,
Sumon
11 years ago
Thank you gentlemen for your replies. I have found the error. I was using the BEA Weblogic drivers for type 4 XA connections. Instead I had to use Microsoft provided drivers for SQL Server 2005 which can be found in sljdbc.jar. The application that i am working on could identify the Microsoft provided derivers only and not the Bea Weblogic drivers.
Hello All,

Greetings!

I am trying to play around with a XML document. In my java code -

I pass the XML document path from my JSP. I am creating a FILE object and then using DocumentBuilderFactory, DocumentBuilder I parse the XML into a Document object. Code snippet-

************************************
public static Document RetrieveXML(String filename) {
String ret = null;
Document doc;
try {
File file = new File(filename);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(file);
doc.getDocumentElement().normalize();
}
catch(Exception e){
e.printStackTrace();
}
return(doc);
}
************************************

Now in my RetrieveXML method, I want to return the Document object so that I can pass it to other methods from my jsp for setting/getting Element value, attribute value. For eg: In this method I want to set the value of an element. I am passing the parsed XML document from above.

public static void setElementValue(Document xmldoc,String strElement,String strValue){}

The problem is that, RetrieveXML does not return the Document object. It is throwing an error. Any idea why?
Is my approach wrong? Any help in this regard will be highly appreciated!

Thanks in Advance,
Best Wishes,
Sumon
11 years ago
Hello All,

I was trying to create a type 4 XA driver JDBC connection pool in Weblogic 8.1 SP5. My database server is SQL Server 2005. I was unable to create the connection and was getting an error [BEA][SQLServer JDBC Driver][SQLServer]Could not find stored procedure 'master..xp_jdbc_open2'. I searched the net and found that I need to install the Weblogic 8.1 SP6.It has a file sqljdbc.dll in it which provided the necessary drivers for creating the Type 4 XA driver connection pool with SQL Server 2005. My connection pools were successful.

Now I am working with an Out-Of-Box application which has a Security Related Module. I created a new Realm in Weblogic and also its corresponding Authenticator,Adjudicator,Role Mapper etc. As per the instructions of the application, it asks me to make the New Realm as the default Realm. After doing all this when I am tring to start my Weblogic server it is throwing an error saying -
Failed to create connection for url=jdbc:bea:sqlserver://TST101:1433;databaseName=CRM7 and dbUser=sa
Nested Exception/Error:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at amdocs.uamsimpl.shared.utils.JDBCConnectionPool.createResource(JDBCConnectionPool.java:164)
at amdocs.uamsimpl.shared.utils.ResourcePool.createResources(ResourcePool.java:935)
at amdocs.uamsimpl.shared.utils.ResourcePool.createConnections(ResourcePool.java:355)
at amdocs.uamsimpl.server.obj.storage.rdbms.JDBCObjectPoolModule.init(JDBCObjectPoolModule.java:104)
at amdocs.uamsimpl.shared.module.UamsModuleManagmentServiceImpl.init(UamsModuleManagmentServiceImpl.java:435)
at amdocs.uamsimpl.shared.module.UamsModuleManagmentServiceImpl.start(UamsModuleManagmentServiceImpl.java:169)
at amdocs.uams.UamsSystem.start(UamsSystem.java:441)
at amdocs.uams.UamsSystem.<clinit>(UamsSystem.java:596)

Can anybody help me out. Any help in this regard will be much appreciated.

Thanks in advance,

Sumon