Nilesh Srivastava

Ranch Hand
+ Follow
since Aug 29, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Nilesh Srivastava

Hi Senthil,

I couldnt get you. Specially when you tell to create folders to place ur class file of Home, Remote and Bean.

Also can we populate these xml files through Weblogic console. If yes HOW?

Also can u tell any good online tutorial or article which we can refer to get a good outline of How to deploy EJB's on WEBLOGIC SERVER. (creating and populating xmls and mf's).

Thanks in Advance
Thanks Ram,

But I think that if we declare Vector as:

Vector v = new Vector(20);

then the default increment value is 20. ie if Vector has to increase its capacity it will increase it by 20. ie doubling the capacity vector.

I am not sure if this occurs with

Vector v = new Vector();

Here the capacityincrement is zero, FINE. so it must be incrementing by 1 at a time.

Please help me clearing my doubts.

Regards,
19 years ago
Hi,

Can we instantiate an ABSTRACT CLASS. I believe the answer is NO. But why?

Also can we have constructors in abstract classes?

Regards,
19 years ago
Hi Neeraj,

But what is the use of declaring member variables in Interface. Implementing class can not have acces to those variables and also interface methods can not use these member variables.
Then what is the use of having member variables in an Interface.


Thanks in advance
19 years ago
Hi,

Can any one tell me , Does interface has member variables. If they, then do all these member variables need to be STATIC AND FINAL. Why is it so? and do these member variables are public(Strictly) or any access modifier will do.

Also, does abstract classes has member variables. DOes all the member variables of abstract class need to be STATIC AND FINAL. Why is it so? and what could be the access modifier of these member variables of abstract class.

Thanks in advance.
19 years ago
Hi ,

One of the standard ways of creating a vector is

Vector v = new Vector();

This way, vector v has an internal array of size 10.But what is the incremental size of this Vector.

That is if I declare a Vector this way and later on during run time I have to add 15 elements to this vector, will this vector add those 15 elements or it will give me some exception?

What is the difference between declaring vector with :

Vector v = new Vector()

and

Vector v = new Vector(10)

Regards,
19 years ago
Hi,

Can anyone tell me how to implement linked list in java without using JAVA API's.

Regards
19 years ago
Hi Shailesh,

Thx for suggestion,but irt depends person to person. And I prefer going through these questions and answers rather than looking into the books.

Regards
20 years ago
Hi All,

1) What is a session management and why do we use session objects.

2) How are sessions objects stored in sessions.

3) What is the difference between storing an object in Application and getServletContext().

I knowthese are very basic questions and I can get all these in any book ..
But I believe that I learned Java more on this site rather than spending time in reading books..

Thanks in advance..
20 years ago
Davendra Jesani
greenhorn
Member # 96380
posted April 15, 2005 07:36 AM
--------------------------------------------------------------------------------
Ive managed to add items to the basket using beans. This is the following code:

HttpSession session = request.getSession();
ItemBean bean = new ItemBean();
bean.setProductID(results.getString("ProductID")); bean.setProductDescription(results.getString("ProductDescription")); bean.setProductName(results.getString("ProductName")); bean.setProductPrice(results.getString("ProductPrice"));
bean.setQuantity(Quantity);
ItemBeans item = (ItemBeans)session.getAttribute("basket");
item.addItemBean(bean);

This now works fine. But my next problem is trying use the information from the bean and storing it to the database. Do you guys know how it is done?

Is this how I will go about getting the details?

HttpSession session = request.getSession();
ItemBeans item = (ItemBeans)session.getAttribute("basket");

To get the product name do I do the following?
item.getProductName() or do I use the session attribute basket?

Basket is the id created in the jsp when using the bean.


Hi Davendra ,

Are you using the type attribute in JSP(jsp:useBean)??
If yes, then it seems fine...

Regards,
20 years ago
Hi,
Thanks for the reply.

Even if I catch Exception in doPost(), I am still getting the same error.

And can you please tell me what can I do coz this is the way I have designed my project.

I want to throw this SQLEception from servlet, and catch it in errorPage(jsp).

Regards,
20 years ago
Hi,

You can do it like this :

while(rs.next())
{
for(int i=0;i<noOfColumns-1;i++)
{
vecHold.add(rs.getString(i+1));
}
vecFinal.add(vecHold);
vecHold
}

I believe this way you can do.Hope this solves your problem.
Nilesh
20 years ago
Hi All,

I am developing a project whose architecture is something like this :

JSP --> Servlet --> Bean(which interactes with DB)

JSP <-- Servlet <-- Bean(which interactes with DB)

Now ,I am trying to catch any exception and display using error page.

Structure of my Bean :

public Vector getDump(String strTblName, String strColNames, String strConditions) throws SQLException, Exception
{
try
{
-- does something
}
catch (SQLException sqle)
{
throw new SQLException(sqle.getMessage()+" -> Error in taking dump");
}
catch(Exception e)
{
throw new Exception(e.getMessage()+" -> Error in Extraction");
}

Now in My servlet I am trying to rethrow the exception so as to catch itis errorPage.

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
if (task.equals("takeDump"))
{
try
{
vecDump = dbMan.getDump(strTblName,strColNames,strConditions);
---- do some work here
}
catch(IOException ioe)
{
throw new IOException(ioe.getMessage()+" -> Error in IO");
}
catch (SQLException sqle)
{
throw new SQLException(sqle.getMessage()+" -> Error in SQL ");
}
}
}
But in the End I am getting error as :

unreported exception java.lang.Exception; must be caught or declared to be thrown :=>> throw new Exception(sqle.getMessage()+" -> Error in SQL");

Even if I change SQLException to Exception, I am getting the same sort of error.


Please help !!!

Thanks in advance.
Nilesh
20 years ago
HI Ben,

What if I use forward instead of sendRedirect. Will I still get the same exception (IllegalStateException).

What is the difference between between the two, forward and sendRedirect.

Can I send parameters with sendRedirect.
With forward I can forward the request . CAn we also forward request with sendRedirect.

Due Regards,
20 years ago
Hi Sarath,

Can you tell me what is the difference between these two.

Thanks in advance.
20 years ago