i have index.jsp
which contains the select box called country
i have the country details in jsp
before loading the index.jsp the values should be fetched from the DB and that value should be listed in the index.jsp
is there any way we can do this functionality using servlets or listeners
Prasanna RamKumar wrote:you mean to say i should implement the business logic from the jsp itself
cant i have my busineess logic seperated from jsp
Yes. Business logic should be separated from the JSP.
When you create select box dynamically you should manipulate the HTML elements using DOM.
select box will be generated from the DOM object only
for the value i will have an arraylist right
i want to fetch the values (country list) before loading my jsp page which will be shown to the user
if iam using the servlet to fetch the values first how can i call the servlet first
should i use any listeners to call the servlet
so that it will first fetch values and set in request attribute so that i can get the attribute in my request scope of jsp
Prasanna RamKumar wrote:if iam using the servlet to fetch the values first how can i call the servlet first. should i use any listeners to call the servlet. So that it will first fetch values and set in request attribute so that i can get the attribute in my request scope of jsp
Use a URL mapping to the servlet for that specific request from the user then in the servlet you can set the List (or what ever) in the request scope and forward the request to the appropriate jsp.
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
Rocket Oven Kickstarter - from the trailbosshttps://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss