• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

problem in using context param for storing database connection information

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Neha k Agrawal
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kiran,
Yes I am using Tomcat.Thank you very much for the help.I am on my way again
reply
    Bookmark Topic Watch Topic
  • New Topic