This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Need to Configure Servlet Init Parameters for the jsp  RSS feed

 
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Why is it essential to configure servlet init parameters for the jsp?

For example,

<web-app>
......
<servlet>
<servlet-name>MyTestInit</servlet-name>
<jsp-file>/TestInit.jsp></jsp-file>
<init-param>
<param-name>email</parama-name>
<param-value>ikickck@gmail.com</param-value>
<init-param>
</servlet>

...........

</web-app>
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get the value like you do in a servlet .
In Jsp you can use implicit object
config.getInitParameter("param_name")
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I cannot understand what is the use of jsp here?

Thanks in advance.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of the time we dont need them, we can do it using setAttribute while forwarding to JSP, right. But if we follow model 1 where JSP page recieves the request and send the reply, there we may need it. What I mean is when JSP page is directly accessed.
 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This case might be applicable when your jsp page is required some parameters for initializing some important stuff.

Assume if you want to connect to a database and also you need following parameters for connecting to the db.
database url, database driver, login id and password.
You can configure all the parameters in config file and read while your jsp page is requested.

The above is an example not the actual case
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right Padma,
It seems making sense here.

But, if in case you are using Scripts in your JSP page. In that case you are supposed to use implicit objects, but won't get request params if you don't define JSP pages over there.

And what if you don't have controller, and your JSP gets hit direct from client?

Guys correct me if I am wrong..
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I accept that it is Model 1 Architecture. But, how does the flow go in the code below?
<web-app>
......
<servlet>
<servlet-name>MyTestInit</servlet-name>
<jsp-file>/TestInit.jsp></jsp-file>
<init-param>
<param-name>email</parama-name>
<param-value>ikickck@gmail.com</param-value>
<init-param>
</servlet>
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It is also to be seen that in Model 1 Architecture, servlets are not there.
Only jsp's are there.

Correct me if i am wrong. Please tell the flow?

Thanks in advance.
 
Shashidhar Yarabati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The flow would be like this:

1. Your index.html asks for the /TestInit.jsp.
2. Container searches for the corresponding servlet class for the TestInit.jsp. (Loads, initilization etc..,)
3. Control (along with the init params) transfered to the Jsp(in this case servlet class).
4. Servlet class gives the response back to the client.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Thanks for the reply.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!