Web tier: servlets, JSP, Web frameworks: JSP calling servlet

  1. JSP calling servlet (2 messages)

    I have a servlet class thats brings out a chart. I want a JSP to call this servlet. Any help.. Please provide a snippet of code.

    Threaded Messages (2)

  2. JSP calling servlet[ Go to top ]

    Hi Shaji,

      In the body of your JSP, just have the following line:

    <jsp:include page="/servletname?any extra parameters" />

    Thats it!

  3. JSP calling servlet[ Go to top ]

    In the servlet output I want to have image and text as output. Since servlet does not support two mime types at a time, I am using servlet to servlet communication but that gives junk characters representing the gif. Below is the code..

    package com.leh.eq.epw.servlets;

    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    import java.awt.*;

        public class SimpleServlet extends HttpServlet
             public void init(ServletConfig config) throws ServletException {



    public void doGet(HttpServletRequest req,
                        HttpServletResponse res) throws ServletException, IOException

            // res.setContentType("multipart/mixed");
         //PrintWriter toClient = res.getWriter();

            ServletOutputStream toClient = res.getOutputStream();
            toClient.println("Thank you for your orderfdd!");

         // Get the request-dispatcher, to send to the client
            RequestDispatcher summary =getServletContext().getRequestDispatcher("/EPW/CostChartServlet?type=sector&ChartX=200&ChartY=200&title=Cost+by+Sector");

         // Have the servlet summarize ; skip summary on error.
            if (summary != null)
            try {
                summary.include(req, res);
             catch (IOException e) {
            catch (ServletException e) {

    public String getServletInfo() {
                  return "com.leh.eq.epw.servlets.Impact Bar Chart Information";