aspose file tools
The moose likes Servlets and the fly likes init parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "init parameters" Watch "init parameters" New topic
Author

init parameters

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 622
Hi Guys,

I wrote the following code:



My web.xml looks like this:



My Questions are:

1). System.out.println(value); is working fine and printing the value on to the console but when I try to display the value onto the browser(in doPost() method) it's not displaying?

2). When I wrote the following code(what is now in init() method) in doPost(), it's not even printing onto the console?
value = getServletConfig().getInitParameter("JndiName");
System.out.println(value);

Can anyone tell me why?

Thanks.


Be Humble... Be Nice.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

Originally posted by Arjun Reddy:
System.out.println(value); is working fine and printing the value on to the console but when I try to display the value onto the browser(in doPost() method) it's not displaying?
I see no place in your code where you are writing the value to the response.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 622
Sorry, but please bear with me. This should be right right?
out.println(value); but the thing is nothing seems to be printing onto the browser.

Thanks.
[ July 11, 2008: Message edited by: Arjun Reddy ]
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Change this

out.println("<h2>value</h2>");


to

out.println("<h2>"+value+"</h2>");


This may fix the problem....


Never try to be a hard-worker. Be a smart-worker.
My Blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

Originally posted by Arjun Reddy:
Sorry, but please bear with me. This should be right right?
out.println(value); but the thing is nothing seems to be printing onto the browser.
That code appears nowhere in your servlet.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12271
    
    1
What actually shows up on the browser? If the browser screen is blank, perhaps the servlet buffer has not actually been written.

Try closing the output stream at the end of the doPost method.

Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: init parameters
 
Similar Threads
default URL and custom URL
Getting error "Oops! This link appears to be broken."
Something wrong with my application
Loop issue in ExceptionHandlerServlet
Get and Post with Init Params