Servlet to HTML

Can anyone enlighten me on a 'clean' way of jumping to html/jsp pages from a servlet. I'm currently using the meta refresh html tag which doesn't particularly work very well.Many ThanksRob Collett
          

<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
Should be between the <HEAD> and </HEAD> tags.

Similar Messages

  • Servlet showing HTML page

    I ma using Tomcat as standalone server.
    have servlet showing HTML page which has frames in it . All frames are linked to some html pages. These pages are stored in
    webapps/project directory and servlet is in
    \Tomcat 4.1\webapps\Project\WEB-INF\classes
    Tomcat can show the servlet with al frames witherror402 means it is unable to take html pages from webapps/project
    what's wrong
    my codes are
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Htmlservlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<HTML>\n"+
    "<HEAD> <TITLE>A frameset document</TITLE></HEAD>\n"+
    "<FRAMESET rows= \"20%,40%,40%\" >" +
    "<FRAME src=\"contents_of_frame3.html\" frameborder=\"0\" scrolling =\"no\">"+
      "<FRAMESET cols=\"*,200\">"+
          "<FRAME src=\"contents_of_frame1.html\" scrolling=\"no\">"+
          "<FRAME src=\"contents_of_frame2.gif\" >"+
    "</FRAMESET>"+
      "<FRAME src=\"contents_of_frame4.html\" frameborder=\"0\"> </FRAMESET>"+
    "</HTML>");
    }

    Hi,
    Please please try this
    <FRAME src=\"/contents_of_frame1.html\"
    thanks,
    nvseenu

  • Servlet into html table ?

    hi
    can i put servlet at html table ?
    how ?
    thanks

    If you mean "can I write from the servlet's Post / Get method into a html table on the client"
    Yes, all you need do is get the response objects Writer()
    (I think the method is response.getWriter())
    then just call println("VALID HTML DOC")
    where VALID HTML DOC is a properly formed html doc to be rendered in the client's browser

  • Problems calling Java Servlets from HTML pages Online

    Hello
    I have created a Web site using Java Servlets, and have acquired some servlet enabled web-space however i am having some difficulty in calling the actual servlets from the HTML pages i was using the line of code as follows
    http://localhost:8080/servlet/....
    followed by the name eg.
    http://localhost:8080/servlet/Login
    however this doesn't seem to be working i have also tried using the exact address of the servlet but this didn't work either
    i.e ..servlet/Login.java
    I was wondering would anyone have any idea as in how the servlets should be called
    Thanks very much

    Once you write the Servlet code, you have to compile and put the classes in the server classpath. To refer these servlets from your pages, you have to configure them in the server configuration(typical a xml file). There you define how you are going to refer to the servlet(/servlet/Logon) and the correponding class.
    -Mak

  • Calling a servlet from HTML

    Is it possible to call a class/servlet from a front-end web page (web page is in HTML form not java form) given that I created my servlet to be executed per class? If there is, can you give me a sample code snippet on how to do this?
    An example on how I call a class in my servlet:
    coordinate c = new coordinate();
    boolean a = c.plot(x,y);
    //do somethingBackground:
    I have already finished creating the server side code for a website and I chose to call a class inside the doPost() method. The class called will be responsible for executing the logic.
    The problem arrives when the web designer created a webpage that requires more than 1 function to be called per page. Since I'm using doPost() which requires the form to be submitted, is there a way to know which submit button is clicked and thus execute the correct function?
    I have a plan that I can fall back to which is to change my code so that it will read variables from the URL instead of thru a method call, but it will take more time since there are a lot of methods. I just thought I ask here if there is a way to accomplish the above so that I can save my code from this mess.
    Thanks,

    My servlet is structured in a way that it calls a method with values that it acquires from the webpage. (The initial plan was to enclose the HTML inside a servlet, but was changed so now I need to incorporate my servlets/services inside the HTML)
    Like in my example, on the coordinate class x and y are acquired from input boxes located in the web page then invoked the method plot(x,y). Since it will be HTML main and servlet sub, I need a way to call plot(x,y) from an HTML page. Or are you saying that my option would be to just create an intermediary servlet that would acquire the input and then call my class to process.

  • Servlet with HTML using JDBC lookup

              Dear Friends
              How are you?
              I am designing a servlet with two drop down lists one on top and the other below.
              I implemented drop down lists using dynamic embedded HTML and SELECT tags.
              I want the user to make a selection in the first drop down list, and the second
              drop down list should display a list based on the selection made in the first
              drop down list.
              Please comment in detail on the most efficient way of achieving this.
              Thanking you
              Very truly yours
              Sriram (Ram) Peddibhotla, PhD
              

    For this I'd probably load all the values for both drop down list and use
              javascript.
              Tinou Bao
              www.tinou.com
              "Sriram (Ram) Peddibhotla" <[email protected]> wrote in message
              news:3b181cd0$[email protected]..
              >
              > Dear Friends
              >
              > How are you?
              >
              > I am designing a servlet with two drop down lists one on top and the other
              below.
              > I implemented drop down lists using dynamic embedded HTML and SELECT tags.
              >
              > I want the user to make a selection in the first drop down list, and the
              second
              > drop down list should display a list based on the selection made in the
              first
              > drop down list.
              >
              > Please comment in detail on the most efficient way of achieving this.
              >
              > Thanking you
              > Very truly yours
              > Sriram (Ram) Peddibhotla, PhD
              

  • New to Servlet - Existing html doc

    I created a new servlet and have an existing html doc. How do I connect the doc to the servlet so that it will send request to the servlet.
    In the html file I have the following code.
    <form action = "/servlet/TEDServicesDatabrowserServlet" method = "post" name ="myName">
    I place the follow in the web.xml file
    <servlet>
    <servlet-name>TEDServicesDatabrowserServlet</servlet-name>
    <servlet-class>mil.navy.nrlssc.dmap.TEDServices.TEDSServer.TEDServicesDatabrowserServlet</servlet-class>
    <init-param>
         <param-name>WorkingDirectory</param-name>
    <param-value>C:\tedsservletworkingdirectory</param-value>
    </init-param>
    <init-param>
         <param-name>ScratchDirectory</param-name>
         <param-value>c:\apache\htdocs\mapb</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    It is not responsing to any request I make. What to do!

    Hello
    A sample web.xml file is attached for your reference.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app id="WebApp">
         <display-name>Web</display-name>
         <filter>
              <filter-name>RedirectFilter</filter-name>
              <display-name>RedirectFilter</display-name>
              <filter-class>test.RedirectFilter</filter-class>
         </filter>
         <filter-mapping>
              <filter-name>RedirectFilter</filter-name>
              <url-pattern>/ResourceLookupServlet</url-pattern>
         </filter-mapping>
         <filter-mapping>
              <filter-name>RedirectFilter</filter-name>
              <servlet-name>ResourceLookupServlet</servlet-name>
         </filter-mapping>
         <servlet>
              <servlet-name>action</servlet-name>
              <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
              <init-param>
                   <param-name>config</param-name>
                   <param-value>WEB-INF/struts-config.xml</param-value>
              </init-param>
              <init-param>
                   <param-name>debug</param-name>
                   <param-value>2</param-value>
              </init-param>
              <init-param>
                   <param-name>detail</param-name>
                   <param-value>2</param-value>
              </init-param>
              <init-param>
                   <param-name>validate</param-name>
                   <param-value>true</param-value>
              </init-param>
              <load-on-startup>2</load-on-startup>
         </servlet>
         <servlet>
              <servlet-name>ResourceLookupServlet</servlet-name>
              <display-name>ResourceLookupServlet</display-name>
              <servlet-class>test.ResourceLookupServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>action</servlet-name>
              <url-pattern>*.do</url-pattern>
         </servlet-mapping>
         <servlet-mapping>
              <servlet-name>ResourceLookupServlet</servlet-name>
              <url-pattern>/ResourceLookupServlet</url-pattern>
         </servlet-mapping>
         <welcome-file-list>
              <welcome-file>index.html</welcome-file>
              <welcome-file>index.htm</welcome-file>
              <welcome-file>index.jsp</welcome-file>
              <welcome-file>default.html</welcome-file>
              <welcome-file>default.htm</welcome-file>
              <welcome-file>default.jsp</welcome-file>
         </welcome-file-list>
         <taglib>
              <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
              <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
         </taglib>
         <taglib>
              <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
              <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
         </taglib>
         <taglib>
              <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
              <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
         </taglib>
         <taglib>
              <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
              <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
         </taglib>
         <taglib>
              <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
              <taglib-location>/WEB-INF/struts-template.tld</taglib-location>
         </taglib>
         <taglib>
              <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
              <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
         </taglib>
    </web-app>
    You are missing the servlet mapping tag. The servlet mapping tag maps the servlet name with a url pattern, so that the web server can understand which servlet to call.
    In your html form specify this url-mapping
    HTH
    VJ

  • Response of a servlet -- a html file

    does anyone know how to do this...
    after processing the clinet request, servlet will return a path of html file that will open in the clinet side..
    if possible tell me the way to do it without jsp bcoz i don't know jsp.

    i have not tried what u have said..anyway thanks.but i have done it another way.and its working fine also..
    out.println("<SCRIPT>window.location.href=\"/redirect.html\" </SCRIPT>");
    piyush

  • Servlet to Html/Jsp

    Can someone enlighten me how to move from servlet code to html/jsp other than using the clumsy meta refresh html code??Many thanksRob Collett
              

    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
    Should be between the <HEAD> and </HEAD> tags.

  • Deploying Servlet with HTML file on Tomcat

    Hi ,
    I created a servlet and an html file. The html file accepts user data and passes it to servlet.
    I want to deploy these two files using Tomcat server. Please tell me a sure procedure for deploying both files.
    Regards,
    ap.

    First of all its better to make a jsp rather than one HTML and a servlet but anyhow in order to deploy it first build your project and create a war file which should contain your HTML and servlet and the web.xml.
    Then place this war file inside the webapps folder of tomcat.Start the tomcat and hit your HTML on the browser....

  • Calling Java - Client application Through Servlet/JSP/HTML

    Hi,
    I have a Java Client Application to display presentation(BI Bean) , made thru wizard provided in JDev.
    Now i want to open this application from a link in HTML page.
    I am running the application thru J Developer only.
    please help,
    thanks,
    Vaibhav

    Hi,
    Thanx for ur help..
    My application is a JSP one..
    My J Client application is named :-
    BIApplication1.java.
    When i call it thru JSP..
    BIApplication1 bi=new BIApplication1();
    bi.setSize(800, 620);
    bi.setVisible(true);
    the application opens..
    but when i attempt to open a presentation..
    it give me the following error..
    "no configuration file found"
    but when i open BIApplication independently..it works just fine...
    thanks,
    Vaibhav

  • Non-expiring web caching (JSP, Servlet, static HTML, GIF, JavaScript, ...)

    Hi,
    I guess this question has been asked 1001 times already ?!
    Well, now it's my turn:
    How can I configure (turn off) web caching in WLS 7 SP2 ?
    Every time I modify JSP code or anything it relates to (JavaScript, GIF, ...),
    I have to restart that server instance and WLS all together !
    Please help !
    Thanks :)

    "Pierre Quilliam"
    I forgot to mention that I've already set pageCheckSeconds to 0 in my webApp's
    weblogic.xml file and ReloadPeriod to 0 in my webApp'sFiles tab.
    Am I still missing something ?
    Thanks :)
    <[email protected]> wrote:
    >
    Hi,
    I guess this question has been asked 1001 times already ?!
    Well, now it's my turn:
    How can I configure (turn off) web caching in WLS 7 SP2 ?
    Every time I modify JSP code or anything it relates to (JavaScript, GIF,
    I have to restart that server instance and WLS all together !
    Please help !
    Thanks :)

  • Best Practice For Referencing JPEG Path Using Servlets To Prepare HTML IMG

    I am migrating a legacy app from Tomcat 5 to Weblogic 11g (10.3). In the legacy app, servlets write HTML that uses relative paths for <IMG src="../images/img.jpeg"> and <script src="../javascript/js.js">. The app is deployed as an exploded archive. Unfortunately, none of the images or script are being loaded. I've tried using http://serverIP:portNum/contextName/images/img.jpeg"> but it doesn't work. I've also checked to get the name of the context in the servlet and it's the root context. Could it have something to do with me having to append .war onto the application when I deploy it? Would it help if I deployed it as a war inside an ear? Basically, I want some best practices for doing this on Weblogic 11g. There are a lot of images and javascript and I'm really hoping they don't have to be inserted using ClassLoader.getResourceAsStream()... thank you.

    Best Practice:
    1. Move Static files like images, css, java scripts to a web server infrastructure if available.
    2. If this is not your case, then please send your directory information how you have packaged your EAR. I can advice :)

  • Html to browser in servlets

    When JSP's are compiled as servlets, does the servlet send HTML to the browser during the html generation or does it send after the complete html is generated?
              Thanks
              AJ

    When JSP's are compiled as servlets, HTML isn't generated. The JSPC compiler
              first generates the Java code for the servlet and then calls the javac
              compiler to compile the generated java code. The resulting servlet's service
              method then executes as a result of being called by the web container. The
              servlet's service method is then free to stream any HTML it generates (by
              whatever means) back to the browser using the response output stream.
              HTML 'generation' is not part of the JSP code gen and compilation process.
              Execution of the servlet's service method is where HTML will be sent to the
              browser as part of the response, if the servlet chooses to do that.
              Bill
              "Anil Jacob" <[email protected]> wrote in message
              news:24477094.1102620616996.JavaMail.root@jserv5...
              > When JSP's are compiled as servlets, does the servlet send HTML to the
              browser during the html generation or does it send after the complete html
              is generated?
              >
              > Thanks
              > AJ
              

  • Servlet-html

    How to send values from servlet to html..
    I retrieve values from database using servlet pgm and want to display in textfield...
    do reply
    thx,
    dish

    You welcome to use my code... the syntax is not 100% for i changed table names, field names, etc for copyright purposes... but this is how i did mine
    You will need to change it according to yur program/output
    Create your SQL statement ...
    =======================================================================================================
    String q8="SELECT *     + "from search_projects "
         + "where queried_user_name = '" + g_user_name + "'";
    os.println("<BR><BR><BR>");
    DisplayQuery(q8, res, "view");
    ========================================================================================================
    static String DisplayQuery(String p_sql,HttpServletResponse res, String p_heading_types)
    throws ServletException,IOException
    PrintWriter os=res.getWriter();
    Statement stmt = null;
    String l_error = "";
    try
    stmt = con.createStatement();
    stmt.execute(p_sql);
    ResultSet rs = stmt.getResultSet();
    if (rs != null)
    DispResultSet(rs, res, p_heading_types);
    rs.close();
    return(p_sql);
    catch (Exception e)
    os.println("<BR><BR>EXCEPTION. Unable to execute. If problem persists, please contact");
    os.println(e);
    return("<BR>ERROR3");
    ===================================================================================================
    static void DispResultSet(ResultSet rs, HttpServletResponse res, String p_heading_types)
    throws ServletException,IOException, SQLException
    PrintWriter os=res.getWriter();
    ResultSetMetaData rsmd = rs.getMetaData ();
    int p=0;
    int numCols = rsmd.getColumnCount ();
    if (p_heading_types.equals("view"))
    while (rs.next())
    os.println("<TABLE BORDER=1 COLS=" + numCols + ">");
         os.println("<TR>");
         os.println("<TD>");
    os.println("<TH><FONT color=blue>Id</FONT></TH>");
    os.println("</TD>");
         os.println("<TD>");
    os.print("<FONT color=black>"+rs.getString(1)+"</FONT></TD>");
         os.println("</TD>");
         os.println("</TR>");
         os.println("<TR>");
         os.println("<TD>");
    os.println("<TH><FONT color=blue>Amount</FONT></TH>");
         os.println("</TD>");
         os.println("<TD>");
    os.print("<FONT color=black>"+rs.getString(2)+"</FONT></TD>");
         os.println("</TD>");
         os.println("</TR>");
         os.println("<TR>");
         os.println("<TD>");
    os.println("<TH><FONT color=blue>rings</FONT></TH>");
         os.println("</TD>");
         os.println("<TD>");
    os.print("<FONT color=black>"+rs.getString(3)+"</FONT></TD>");
         os.println("</TD>");
         os.println("</TR>");
         os.println("<TR>");
         os.println("<TD>");
    os.println("<TH><FONT color=blue>Date</FONT></TH>");
         os.println("</TD>");
         os.println("<TD>");
    os.print("<FONT color=black>"+rs.getString(4)+"</FONT></TD>");
         os.println("</TD>");
         os.println("</TR>");
         os.println("<TR>");
         os.println("<TD>");
    os.println("<TH><FONT color=blue>Email</FONT></TH>");
         os.println("</TD>");
         os.println("<TD>");
    os.print("<FONT color=black>"+rs.getString(5)+"</FONT></TD>");
         os.println("</TD>");
         os.println("</TR>");
    os.println("</TABLE>");
    os.println("<BR><BR><BR>");
    p=p+1;
    Thanks
    Naren

Maybe you are looking for