Kumar Navin

Ranch Hand
+ Follow
since May 27, 2004
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 Kumar Navin

Recently I came across a way of retrieving values from an array as below:



The end result of output was the same in both the cases, with % and without %.
What is the advantage/disadvantage when we retrieve like " listofvalues[i % listofvalues.length]" from an array.

Regards,
-Kumar.
9 years ago
Thanks Paul. I was able to find the error. You are right, I was treating attribute as an element.
No more response needed.
I have an XML as below to parse:
<LoadTicketRequest>
<LoadTicket LoadTicketID="S-123345">
.....
</LoadTicket>
</LoadTicketRequest>

But am not able to fetch the value of LoadTicketId attribute.

My code snippet is as below:
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xmlRecords));
Document doc = db.parse(is);
NodeList nodes = doc.getElementsByTagName("LoadTicket");
Element ticketelement = (Element) nodes.item(0);
NodeList ticketid = ticketelement.getElementsByTagName("LoadTicketID");
Element eticketid = (Element) ticketid.item(0);
System.out.println( "Ticket ID : " + getCharacterDataFromElement(eticketid) );

Can someone help me out as to where am going wrong.
Sarika,
Did you ever tried RequestDispatcher interface. It has the facility of passing on the request object and then the information be retrieved on the page before a response is sent.
18 years ago
JSP
Hi! Avi,
quote:"pardon me if this is a silly question......" unquote.
But the task here is seperated. Certain issues in AS unknown at my level has forced to opt for another server. Now, even the thing might be moved to Tomcat, if the issues are not resolved.

Hi! Carol,
Tried the wlclient.jar, but didn't work. Nevertheless weblogic.jar also contains weblogin.jndi.WLInitialContextFactory class

Regards,
-Navin.
19 years ago
Hi! Friends,
Am trying to access a Stateless EJB(deployed on Weblogic 8.1) through a servlet running on 9i AS, but is giving an exception as below :
NamingException Thrown : Cannot instantiate class: weblogic.jndi.WLInitialContextFactory

The code snippet in my Servlet is as follows:
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL, "t3://10.127.0.1:7001");
Context context = new InitialContext(prop);

I have put weblogic.jar in lib directory under WEB-INF.
It's working fine if the Servlet is called from Weblogic itself.
Any help is highly appreciated. Thanks in advance.

-Navin.
19 years ago
Hi! Friends,
Am trying to execute a servlet on Tomcat which calls an EJB running on Weblogic 8.1. Configured the web.xml file for Servlet also. But am getting an error message as:
///// ERROR MESSAGE //////
javax.servlet.ServletException: Servlet execution threw an exception
java.lang.NoClassDefFoundError: weblogic/rmi/extensions/server/Stub

The same servlet works fine on Weblogic. Is there any path to be set or parameters to be set for the same.
Any sort of help is highly appreciated.

-Navin.
19 years ago
Actually my task is to execute a logic daily at a particular time. Right now I have used a java Program and added it to the scheduler, which invokes the servlet daily.
Is there any other way to accomplish this.
Thanks.
19 years ago
Hi!
Is there a way to schedule the execution of a Servlet in an AS ? If yes, how to achieve this ?
Thanks,
-Navin.
19 years ago
Hi! Friends,
Am trying to use Oracle Thin Driver in a java bean which establishes a connection. But it is giving ClassNotFoundException. I have placed the jar file containing the Oracle Driver in the classpath. The same connection code worked fine with standalone application as well as 9iAS.
The snippet is as follows:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc racle:thin:@ip_of_DBServer ort_no:server","usernm","passwd");

Any kind of help ?
-Navin.
19 years ago
I mean the DAO class, not the server. Your servlet is being executed on the server and hence the Servlet Engine must have access to all the classes that your servlet is using.
Hope you'll get it now.
19 years ago
Try this out:
request.getRemoteAddr();
It returns the IP address from which the resource have been requested. Returns as a String.
Best of luck.
19 years ago
JSP
Just check out if your server is able to load the DAO class or not ???
It might be unavailable.
19 years ago
Hi! Friends,
Am new to 9iAS. Trying to deploy a Stateless EJB. After creating the class files, I create
the jar file myfirstejb.jar which has:
1)All the class files
2)META-INF/ejb-jar.xml
3)META-INF/orion-ejb-jar.xml

Then I create an ear file myfirstejb.ear which has:
1) myfirstejb.jar
2) META-INF/application.xml

But when I try to deploy, it gives an error as :
Invalid J2EE application file specified - Cannot get xml document by parsing META-INF/ejb-jar.xml in myfirstejb.jar: Unexpected EOF.

My xml files have the following entries;

ejb-jar.xml
-----------
<ejb-jar>
<enterprise-beans>
<session>
<description>Session Bean (Stateless)</description>
<display-name>MySessionEJB</display-name>
<ejb-name>MySessionEJB</ejb-name>
<home>MySessionEJBHome</home>
<remote>MySessionEJB</remote>
<ejb-class>MySessionEJBBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<ejb-jar>

orion-ejb-jar.xml
-----------------
<orion-ejb-jar>
<enterprise-beans>
<session-deployment name="MySessionEJB" location="MySessionEJBBean" />
</enterprise-beans>

</orion-ejb-jar>


application.xml
---------------
<application>
<description>Session Bean (Stateless)</description>
<module>
<ejb>myfirstejb.jar</ejb>
</module>
</application>

Can you guide me, for the same. This is how I did in Weblogic.

-Navin.
19 years ago
Hi! Friends,
My problem might seem to be a repetitive one, but am not able to debug it. I have written a class which invokes a Servlet using net package but is giving an error.
The code snippet of class is as follows:
public static void main(String args[])
{
URL url = new URL("http://12.125.0.15/MyProj/servlet/MyServlet");

URLConnection con = url.openConnection();
System.out.println("Received a : " + con.getClass().getName());

con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);

System.out.println("Getting an output stream...");
OutputStream os = con.getOutputStream();
String msg = "Message from client";
OutputStreamWriter osw = new OutputStreamWriter(os);
osw.write(msg);
osw.flush();
osw.close();
System.out.println("After flushing output stream. ");

System.out.println("Getting an input stream...");
InputStream is = con.getInputStream();
// any response?
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = null;
......
}

When I execute this code from the command line, it gives an error as such:

java.io.IOException: Server returned HTTP response code: 405 for URL: http://12.125.0.15/sec/servlet/MailServlet
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at GoodURLPost.main(GoodURLPost.java:38)
...........................................................................
I have tried the links I found on Javaranch for the similar problem but in vain. Can anybody rectify the mistake or suggest something.
Thanks,

-Navin.
19 years ago