• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get dynamic content in index.jsp page

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is my first sevlet/jsp application.. so question might be dumb..

In my application, When the user opens the website, he will open index.jsp, now I have to get dynamic content inside this page. But the problem is that he is not requesting any servlet as of yet.. So how to get dynamic content in first page ?
one option was to, create index.jsp and redirect it to a servlet.. that servlet gets all the information needed on first page and then redirects that info to "home.jsp".. is this good option? or are there any other options?
thanks in advanve


 
Sheriff
Posts: 67746
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
Redefine the "welcome file" to your servlet rather than index.jsp.
 
chintu reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Bier..

how to do that? is that done in web.xml?
 
chintu reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok got it.. <welcome-file-list> in web.xml.. thanks
 
chintu reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one more question...

is it a good practice to give servlet paths in hyperlinks? i mean menu bar in each page has links to other pages. when the user clicks that link, that page opens with dynamic content.. right now i am giving path to servlet(defined in web.xml) and redirecting from there to a jsp page.. is there any other way to do it?
 
Bear Bibeault
Sheriff
Posts: 67746
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
Why would you want to do it any other way?
 
chintu reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lets say, a user wanted to check his course list.. there is a link on the menu bar "my course list"... right now im linking that to "courselist.do" and that redirects to courselist.jsp page

once a user opens that page url is saved in web history in the browser.. in case some clever (or stupid) user instead of going through the link on the menubar, directly enters the url to the jsp page then the jsp page loads but it doesn't show any content as no content was drawn from servlet... i was thinking how to get around this..
 
Bear Bibeault
Sheriff
Posts: 67746
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
I missed the part about redirecting. Why is your controller redirecting rather than forwarding?

Your JSP pages should also be hidden under WEB-INF so that they cannot be addressed via the browser.
 
chintu reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh sorry.. i meant forward only.. not redirect......

so all the jsp pages that are supposed to be open after an action should be put under web-inf.. right?

thanks a lot
 
Bear Bibeault
Sheriff
Posts: 67746
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
Not web-inf, WEB-INF.

If you forward rather than redirect, the address of the JSP is never exposed.
 
chintu reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok.. that solves my problem.. thanks a lot....

now my next quest is to learn tag libraries and use them to display content in jsps.. can you suggest me some good startup material.. i have absolutely no idea abt tag libraries.. very difficult to understand the working procedure from sun's tutorial...
 
Bear Bibeault
Sheriff
Posts: 67746
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
"abt"?
 
chintu reddy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
about
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic