Amol Nayak

Ranch Hand
+ Follow
since Oct 26, 2006
Merit badge: grant badges
For More
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 Amol Nayak

If you have a method(s) that will be common to all the subclasses, using abstract class makes more sense rather than defining interface and forcing all the implementing classes to implement them.

Since we are on the Servlets forum. check out the two classes javax.servlet.GenericServlet and javax.servlet.http.HttpServlet

Also check this link out
13 years ago
use the getResourceAsStream() method of the ServletContext to read the properties file as stream. I am assuming your properties file is not outside the web application

Since your are reading the properties file in a non servlet class, get the stream in a servlet and pass the InputStream to your java class.
13 years ago

EJB 3.0 expalins deployment descriptors not required, if that is true how and where should i configure pool of instances ?

You dont specify pool settings in deployment descriptor, it is done in an application server vendor specific way.
What are the common classes you said are required for both ear and jar? I will suggest you dont duplicate them in both the applications but rather create a Shared library in Websphere and link both these applications to this shared library.

Are you getting a java.lang.NoClassDefFoundError for one of those common classes?
Yes we can use two Datasources in a way you are using. What is not working out for you?

Now in my application, I have a statement in one of the source files as follows:

Which application is it? An EJB application, a Web application..?

The private variable 'localClassPath' of ClassLoader stores the semi-colon separated paths of various required projects and jar files in an application. But this variable has everything except the path to 'resources' folder.

What all have you got in your EAR? What do you see in this variable?

First of all, your class VerifyCredentials is NOT an HttpServlet (I see it nowhere extending javax.servlet.http.HttpServlet interface).
Hence, you can't call getServletContext() method. If your class were to implement javax.servlet.http.HttpServlet, then the copile-time error would be gone.

javax.servlet.http.HttpServlet is a class which implements javax.servlet.Servlet interface. You extend and not implement javax.servlet.http.HttpServlet
13 years ago

So i gave the form action tag in JSP as follows <form name="input" method="post" action="JdbcServlet">

This will post to http://localhost:8081/Test/JdbcServlet

my worry is not about the wrong path the server is going to.

I have given the servlet path as "" in web.xml but the URL after submitting the JSP page is http://localhost:8081/Test/master/register/JdbcServlet.

Also its giving a 404 error at http://localhost:8081/Test/master/register/JdbcServlet. is the servlet class and not the servlet path. /master/register/* is the url pattern.
i hope you are not expecting any result by entering http://localhost:8081/Test/master/register/JdbcServlet from the browser as your have not overridden the doGet method

Prasad Krishnegowda wrote:you have to change in both sides, change the action attribute in the jsp and servlet-mapping in web.xml to /com/pg/sebastian/sebastian/servlet/JdbcServlet

/com/pg/sebastian/sebastian/servlet/JdbcServlet in url-pattern for web.xml
com/pg/sebastian/sebastian/servlet/JdbcServlet in action of form (note there is no leading /).

Jyoti please explain what are you trying to achieve clearly
13 years ago
ServletContext is a plain java object and can be accessed from any java class if
1. You either set it after constructing the object
2. Pass it as a parameter to the Constructor of the class you instantiate.

However it is not a good idea to inject into a plain java class with any Servlet API related classes.

For the below scenario i will sucggest the below.

1. Define a ServletContextListener where you instantiate the Database class and store it in a servlet context (you seem to have already done this part).
2. Inject this Database class from the controller into this VerifyCredentials class either using a setter (after instantiation) or constructor.
3. Invoke the verity method.

13 years ago
Hi Amrita,
I have communicated in my previous post what your problem might be. Your tomcat installation looks to be messed up (based on what your have posted in your other post). As suggested in other forum try reinstalling tomcat and both of your problems will be sorted out.

Also NoClassDefFoundError is an Error as the name suggests, not an Exception
13 years ago
Not too sure of weblogic console but i havent come across any such utility in the other application server's console, i doubt if you will find one. Logically a console is used to deploy an application and not generate one to be deployed.
However if you find this Command prompt approach to be tedious you can use ant to build your app.

If you still want one simpler approach specific to your test projects, why not have a bat file prepared to build the war file.
13 years ago
Check this out first


Please show what you have worked on it so far. Any code written, any searches made etc ?
13 years ago

Rahul wrote:
C:\myApp> jar -cvf myApp.war *.class

Though this will generate a .war file it is not as per the directory structure required for a WAR file as per specification. The class files will be present in the root of the war which are supposed to be present in WEB-INF/classes

Rajendra wrote
hi raghul , how the same war file generation in console .(you explained in command prompt)

Which console?
13 years ago

I keep getting the same error due to improper parsing of: String sqlStatement = "INSERT INTO user (firstName,userName,password,email,userRole) VALUES ("+fName,uName,pw,em,userRole+");";

Is this a valid java statement?

Hint: look at the string marked in bold.
there is no such class javax.servlet.ServletFileUpload in servlet API.

However any classes you are not able to find from javax.servlet package is due to same problem you have in the post
package apache.commons not exists
13 years ago