简体   繁体   中英

I am trying to create a JSP Page with frames

I am trying to create a JSP page which will contain multiple section. Each section will contain data fetched from data base using servlet. I tried using frame and have put frame src ="servlet" and in servlet data is being fetched and forward that to jsp which I want to be displayed inside the frame?? Anyone having some idea for this.

I often want to achieve similar things and do so by setting attributes on the HttpServletRequest object.

Servlet:

User user = userBean.getUser(231); 
Job job = user.getJob();

request.setAttribute("user",user);
request.setAttribute("job",job);

request.getRequestDispatcher( url ).forward(request, response);

JSP Page

<div id="section1">
    ${user.name} 
    ${user.age}
</div>

<div id="section2">
    ${job.title} 
    ${job.wage}
</div>

Notes

Frame is an old HTML Element and not compatible with HTML5 I've used divs in my example, but you could use HTML5 Section to provide more smeantic meaning.


Hope I've understood your problem and this helps.

Good luck

Adam

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM