How can I use a servlet to generate a site using frames?

Vincent Cirel

In general, look at each frame as a unique document capable of sending its own requests and receiving its own responses. You can create a top servlet (say, FrameServlet) that upon invocation creates the frame layout you desire and sets the SRC parameters for the frame tags to be another servlet, a static page or any other legal value for SRC.

---------------------- SAMPLE ----------------------

  public void doGet(HttpServletRequest request,
     HttpServletResponse response) throws ServletException, IOException {                                               
    PrintWriter out = new PrintWriter (response.getWriter());        

    out.println("<head>Your Title</head>");

    // definingthe three rows of Frames for the main page
    // top      : frm_1
    // middle : frm_2
    // bottom : frm_3

    out.println("<frameset rows=12%,70%,* cols=*>");
    out.println("<frame src=/servlets/MenuServlet                name=frm_1>");
    out.println("<frame src=/servlets/DummyServlet?mode=full     name=frm_2>");
    out.println("<frame src=/servlets/DummyServlet?mode=small  name=frm_3>");

-------------------------- END ------------------------------------------
Where MenuServlet and DummyServlet provide content and behavior for the frames generated by FrameServlet.

Hope this helps.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact