File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes problem in using context param for storing database connection information Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem in using context param for storing database connection information" Watch "problem in using context param for storing database connection information" New topic
Author

problem in using context param for storing database connection information

Neha k Agrawal
Greenhorn

Joined: Mar 25, 2008
Posts: 25
Hello Friends,
I am new to struts & jsp.I am developing a project in struts.I have 1 jsp page called editProfile.jsp.On submitting this page it will call 1 action class.The action class in turn will call the Plain old java class where I have written the logic for updating User Profile.

I have created context-param in web.xml for database connection information like dbURL , dbUserName , dbPassword , jdbcDriver.Now I want to use these connection information in my Business logic(Plain Old Java Class).As we can use context parameter only in jsp & servlets , I am setting the variables of my business logic class with these context param in jsp itself.

now when I am calling the updateProfile method of Business logic class from Action class it is giving error as all the connection variables which I set in jsp for my business logic class has become null again.

I am not getting.If once I have set those variables how come they are becoming null again???Please help me.Any Help will be highly appreciated.Thank you in advance.
[ May 11, 2008: Message edited by: Neha k Agrawal ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

So you are saying that you are obtaining the values of the context parameters in your action, and upon passing them to the POJO they become null? Sounds like a problem in your logic. Have you debugged every step of the way to determine at what point the values are nullified?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Neha k Agrawal
Greenhorn

Joined: Mar 25, 2008
Posts: 25
This is the code I have written
I have debugged it.I think the problem is that another instance of EditProfile.java class (My business logic class) is getting created when I am calling it from action class.But I am not getting how to avoid it.Please take a look at the code.


web.xml file



EditProfile.jsp



EditActionProfile.java





EditProfile.java class (My Business Logic Class)



[ May 11, 2008: Message edited by: Neha k Agrawal ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
Neha k Agrawal
Greenhorn

Joined: Mar 25, 2008
Posts: 25
I am sorry my post was not easy to read.I was not aware of UBB code.I will make sure that I am making use of UBB code in every post.I have changed my post.Can you please help me now??
K Kiran Kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 109
Hi Neha,

What is the server that you were using to deploy this application? Is it Tomcat?? If so I you can also configure the database info in server.xml file's context path tag. For more info, check the following site

http://static.raibledesigns.com/downloads/howto-tomcat-jotm.html

Regards,
Kiran.
Neha k Agrawal
Greenhorn

Joined: Mar 25, 2008
Posts: 25
Hi Kiran,
Yes I am using Tomcat.Thank you very much for the help.I am on my way again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in using context param for storing database connection information
 
Similar Threads
Anyone know of free servets/jsp hosting?
Action in struts
failure to activate a Web application with database
Webservices and Request/Response
about struts