Results 1 to 6 of 6

Thread: Creating new Header in JSP

  1. #1
    Join Date
    Nov 2009
    Posts
    862

    Creating new Header in JSP

    Hello, I am working on java. Currently I am learning java. While learning it, I am getting problem while creating a custom header. I am making use of the Tomcat 5 and it is giving problem. I have not added the below code in my program:
    Code:
    <%
    response.setHeader ( "DDD", "iiii");
    %>
    There is nothing on my page. Can anyone give me help on this.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Creating new Header in JSP

    I have code below for creating the HTTP header:
    Code:
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class ServletTesting extends HttpServlet 
    {
    private static final long version = 1L;
    Public ServletTesting ()
    {
    super ();
    }
    protected void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    {
    res.setHeader ( "myVar", "thousand");
    res.sendRedirect ( "deux.jsp");
    System.out.println ("***** get ******");
    }
    protected void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    {
    }
    }

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Creating new Header in JSP

    As you are telling that you have omitted the code below which you need to add in your program. It will solve your problem.
    Code:
    <%
    response.setHeader ( "DDD", "iiii");
    %>

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Creating new Header in JSP

    I am having following code of the Header in jsp :
    Code:
    <%-- set content type and character set --%>
    
    <%@ page contentType="text/html;charset=WINDOWS-1252"%>
    
    <%-- include the JML taglib for use in the JSPs of the application --%>
    
    <%@ taglib uri="-----------------" prefix="-------" %>
    
    <%-- include the HeaderBean and HotelBean --%>
    <jsp:useBean id="head" class="HeaderBean" scope="application" />
    <jsp:useBean id="hrs" class="HotelBean" scope="session" >
      <%-- Create a Connection object --%>
      <% hrs.dbConnection(); %>
    </jsp:useBean>

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Creating new Header in JSP

    I am not having great knowledge of java, but as you are not included the code below :
    Code:
    <%
    response.setHeader ( "DDD", "iiii");
    %>
    You can check whether you are getting the problem by adding it or not. It may possible that your problem would get solved by this and you get the solution. So, just try it and solve the problem.

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Creating new Header in JSP

    I have created the code below for displaying the Header "Variable":
    Code:
    <% @ Page language = "java" contentType = "text / html; charset = ISO-8859-1"
    contentType = "ISO-8859-1"%>
    <% @ page import = "java.util .*"%>
    <% @ page import = "com.sun.net.httpserver.HttpContext"%>
    DOCTYPE html 
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title> Insert title here </ title>
    </ head>
    <body>
    <% = request.getHeader ( "variable")%>
    <br/>
    <%
    HeaderName HName = "";
    for (Enumeration enum = request.getHeaderNames ();
    enum.hasMoreElements ()
    {
    HeaderName = (HName) enum.nextElement ();
    out.println (HeaderName +":"+ request.getHeader
    (HeaderName) + "<br/>");
    }
    %>
    </ Body>
    </ html>

Similar Threads

  1. Connect USB 3.0 front case panel header to motherboard w/o a header?
    By Dogs-Day-Out in forum Motherboard Processor & RAM
    Replies: 4
    Last Post: 14-04-2012, 07:02 PM
  2. Why we use Header Files
    By Jaiwanti in forum Software Development
    Replies: 3
    Last Post: 19-11-2009, 08:25 AM
  3. IIS7: Add expires header or cache-control header
    By quota in forum Software Development
    Replies: 3
    Last Post: 06-06-2009, 07:45 PM
  4. Php header problem
    By Deskmukh in forum Software Development
    Replies: 3
    Last Post: 07-05-2009, 07:41 PM
  5. Help Regarding Header Files
    By Jagdish Gada in forum Software Development
    Replies: 4
    Last Post: 06-03-2009, 12:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,221,960.20728 seconds with 17 queries