A servlet generating a frameset.

Hi,
I want my servlet to generate a frameset. One of the frames is supposed to start another servlet and the other one is supposed to start a normal html file. But when I start my servlet, I get the error "*.class is not found" for the frame which is supposed to start a HTML file. It looks like the browser is lookind for another servlet even though it shouldnt.
But the starting of the other servlet from the generated frame works fine.
Here is the servlet that generates the frameset:
package usul;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class StartChat extends HttpServlet
public void doGet(HttpServletRequest request,HttpServletResponse response)
       throws ServletException, IOException
  //NAMEN HOLEN
  String name = request.getParameter("UserName");
  if(name == null)
   name = "ANONYM";
  //ANTWORTEN
  PrintWriter out = response.getWriter();
  String retHTML = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
  retHTML = retHTML + "<html><head><title>Chat</title></head>";
  retHTML = retHTML + "<frameset rows=\"80%,*\"><frameset cols=\"80%,*\">";
  retHTML = retHTML + "<frame src=\"http://www.mycgiserver.com/servlet/usul.Chat?UserName=" + name + "\" name=\"Nachrichten\">";
  retHTML = retHTML + "<frame src=\"Users.html\" name=\"Users\"></frameset>";
  retHTML = retHTML + "<frame src=\"Send.html\" name=\"Senden\"><noframes><body>";
  retHTML = retHTML + "<p>Ihr Browser unterstuetzt keine Frames</p></body>";
  retHTML = retHTML + "</noframes></frameset></html>";
  out.println(retHTML);
}To put it in a nutshell:
<frame src=\"http://www.mycgiserver.com/servlet/usul.Chat?UserName=" + name + "\" name=\"Nachrichten\">
works fine, but the html frames like
<frame src=\"Send.html\" name=\"Senden\">
dont work.
Why?
thanx

The browser is probably looking forthe HTML files as being relative to the servlet directory where the first servlet was called from. Try using an absolute path to the HTML or
retHTML = retHTML + "<frame src=\"/Send.html\" name=\"Senden\"><noframes><body>";
assuming that Send.html is in the webapp's root directory.

Similar Messages

  • Tomcat 4.1.18 where to find servlet generated from jsp?

    hi all
    i need to know where to find the servlets generated by compiling my jsp pages.
    i'm using tomcat 4.1.18.
    shall i set some property in the conf/server.xml file to do this?
    i need this feature to debug my application, since when i get some exception, all the references are to the servlet, not to my jsp (line number ecc..)
    thanx a lot in advance
    sandro

    it will be under your tomcat directory. for example if you have a webapp called foo123 the servlet code for the jsps will be under
    c:\your_tomcat_dir\work\Standalone\localhost\foo123
    -S-

  • JAR file does not get uploaded to client for my SERVLET generated APPLET

    Some help please...
    I have a servlet that generates the HTML code that contains an APPLET. This APPLET needs a JAR file that is listed under its ARCHIVE property. The SERVLET is in a JAR file that is in the same directory as the other needed JAR file. If I create a static HTML with the output of the SERVLET it works fine. But if go through Weblogic the needed JAR file does not get uploaded to the client so I get a java.lang.NoClassDefFoundError:and my APPLET does not load.
    Q1: I am not sure what to put under the CODEBASE tag. I tried "." and I also tried "http://mymachine" but both did not work. I also tried without the CODEBASE tag. No luck. The SERVLET is bound to http://mymachine/servlet.
    Q2: Does anyone have any suggestions on how to do this? Is there a way to force the browser to upload a certain JAR file?
    Thanks...

    It works!!
    This is what I did:
    The jar file in question was the weblogic.jar. I tried putting it under the lib directory of my war file but I had problems because the weblogic.jar contains other war files inside so when I tried to deploy my war file it also tried to deploy the inner war files which for some reason did not work. So I tried removing the war files from the weblogic.jar and this time I had no problems deploying my war file but I still could not find the classes I needed. So I tried moving the weblogic.jar to the root dir of my war file and it worked!! Now the trick here was: I did not set the CODEBASE AND I had the ARCHIVE paramenter set in TWO places like below:
    <APPLET CODE = "marketmap.client.MarketMapApplet"
    ARCHIVE = "weblogic.jar"
    WIDTH = "657"
    HEIGHT = "382"
    ALIGN = "BOTTOM"
    ALT = "APPLET tag not recognized">
    </XMP>
    <PARAM NAME = CODE VALUE = "MyApplet" >
    <PARAM NAME = "type" VALUE="application/x-java-applet;version=1.2.2">
    <PARAM NAME = "scriptable" VALUE="false">
    <PARAM NAME = ARCHIVE VALUE="weblogic.jar">
    </APPLET>
    Actually if you do not place a parameter named ARCHIVE (at the end) it wil NOT work. I tried with multiple jar files listed and it works great too.
    Anyway I figure I'd share. Thanks for the help too.
    Lastly for people who choose not to upload the jar files to clients, you should look at the bea documentation on applets. It lists a classpath servlet that allows you to provide classes to the clients without having to force them to download the jar file.

  • Servlet generating an id.

    Hello. I was wondering how to implement a servlet that generates a unique id instead of the database doing it?
    Hm... Let's say I have a class that contains 2 Strings and an int for the unique id. This is then saved to the db. Note that there can be duplicate entries with only the unique id that makes them differ. How's that in a servlet? Or is there an SQL syntax that after you save the info the id generated by the database is returned?
    No need to post any code. I just kind of want to know kind of the basics on how to do it.

    Did you see the java.util.Random class?
    Do the first 7 digits have to be distinct from each other, or you just want the whole thing to be unique (IDs should be unique, after all, but the digits need not be, for most cases).
    Write some code and ask a specific question when you get stuck. Include your code within code tags (see CODE button above posting box).

  • Problem opening servlet generated PDF in browser

    This is the code i use to show the PDF in a browser
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    res.setContentType("application/pdf");
    res.setHeader("Content-Disposition","inline;Filename= " + file.getName());
    ServletOutputStream sos = res.getOutputStream();
                   outStream.writeTo(sos);
                   sos.flush();          
                   outStream.close();
                   sos.close();
    In Netscape i get an error saying the filename does not start with %PDF and in IE the page just shows up blank. from the blank pagewhen i use the back button and then hit the forward button the pdf will show up in IE.
    I also tries using fileOuput stream instead of servletoutputstream
         FileOutputStream fout = new FileOutputStream( file );
                   outStream.writeTo(fout);
                   fout.close() ;
                   outStream.close() ;
    In this case IE does nothing but it works on netscape or mozilla
    This is running on websphere 5.0 , apache webserver on linux env
    But i need to get this worked on IE any help would be greatly appreciated!
    Thanks in Advance
    Sid

    (SIGH)
    Crossposted over here:
    http://forum.java.sun.com/thread.jspa?threadID=631107

  • Servlet generated PDF wont show up in browser

    This is the code i use to show the PDF in a browser
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    res.setContentType("application/pdf");
    res.setHeader("Content-Disposition","inline;Filename= " + file.getName());
    ServletOutputStream sos = res.getOutputStream();
                   outStream.writeTo(sos);
                   sos.flush();          
                   outStream.close();
                   sos.close();
    In Netscape i get an error saying the filename does not start with %PDF and in IE the page just shows up blank. from the blank pagewhen i use the back button and then hit the forward button the pdf will show up in IE.
    I also tries using fileOuput stream instead of servletoutputstream
         FileOutputStream fout = new FileOutputStream( file );
                   outStream.writeTo(fout);
                   fout.close() ;
                   outStream.close() ;
    In this case IE does nothing but it works on netscape or mozilla
    This is running on websphere 5.0 , apache webserver on linux env
    But i need to get this worked on IE any help would be greatly appreciated!
    Thanks in Advance
    Sid

    I just skipped posting over the actual pdf write code.
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    //Write bytes to the PDF
    writer = createDocument(document, outStream);
    res.setContentType("applicatio�n/pdf");
    res.setHeader("Content-Disposi�tion","inline;Filename= " +
    file.getName());
    ServletOutputStream sos = res.getOutputStream();
    outStream.writeTo(sos);
    sos.flush();
    outStream.close();
    sos.close();
    If i use fileOutputStream i can see that the file is being created physically without any problem. It would not though open up in the Browser!
    Thanks
    Sid

  • How to display images on a servlet generated page???

    Hi, I am developing an app in which I must display some messages, each message may have an image. The images are saved in the database. I do not want to save the image on the filesystem but instead of that I want to send the image as an attribute to the page but I dont know then how to display it. I have no idea about how to do that! Any help on this would be very appreciated!

    mmm yes I know that the img tag displays an image but I am asking how to display the image without saving the file into the server filesystem, I mean something like:
    1.- getting the bytes from the Database
    2.- getting an Image object
    3.- pasing it to the request as an attribute
    4.- getting that attribute from the request
    5.- displaying it on somehow directly from the image var or something.
    the src parameter of the img tag takes as a string the path of the image, but i dont want to save it.

  • How to display  servlet dynamically generated image ?

    Hi,
    How to display servlet dynamically generated image ?
    I have a servlet generating a buffered image in the doGet. I want to display the image in a jsp page with other information. I'm not able to get it properly displayed.
    **Try n# 1 **************************************************************
    This displays my image but nothing elle :
    ServletOutputStream sos = pResponse.getOutputStream();
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
    encoder.encode(img);
    **Try n# 2 ****************************************************************
    I tried also :
    In the servlet :
         request.setAttribute("renderedImage", img);
    and in the jsp page :
         BufferedImage image = (BufferedImage) request.getAttribute("renderedImage");
         <img src="<%=ImageIO.write(image,"jpeg",response.getOutputStream())%>" width="300" height="280"/>
    This last try draws big crap in the jsp page, thank you in advance.
    Nelson

    Call another servlet from the IMG tag. Have the servlet stream out the image using ImageIO (instead of writing HTML).

  • How can I generate a html page in a servlet-applet connection?

    Hello, I have an applet which contains an ok button, when I click this button, I need that servlet generate an html page and view it in browser. How can I do this?
    Thanks

    But with this method only is possible I think open a page web, and if it is possible call url of the servlet, you generate other request and response object (other call to method doGet or doPost because ShowDocument needs parameter url), so the previously request when I click button ok it's no the same and how I obtain the prinwriter from first request, showDocument don't obtain html page from printwriter.

  • Recall the servlet after it had generated the "response"  page

    Hi Everybody !
    I have a big problem and i am front it since i am programming in servlet/jsp .
    The basic scheme in the tutorial is form.jsp => call and processing by the servlet => response.jsp .
    That i want to do is : simple form.jsp=> call and processing by the servlet (with method 1) => response1.jsp (which is a more complete form) => call and processing by the servlet (with method 2 which it is unlike method 1) => response2.jsp (final page).
    But i don't know how to do it : you don't understand with i want to make it ? so there is a simple example: a user want to know what he have eaten at a day:
    1)my first simple form.jsp: ask to the user his name and a date
    2)the response 1 and page 2 is return: it's a more complex and complete form (this page is well generate in my project )
    with this date and the name of the user, i question my database : "what this user have eaten at this date "?
    For example : at this date, he ate : chips at the aperitif and apple for dessert .
    The user must to complete the page 2 with more information (which have to be insert in the database):
    ex:
    had he ate this apple : in the kitchen, in the park, at his work ...?? (drop-down menu)
    had he ate this apple : baked, uncured ...?? (another drop-down menu)
    To resume: i want it's to recall the servlet with another button (with a name different in the servlet) to a specific method.
    in the first and simple form there is a button ONE that call the method1 of the servlet
    the servlet generate the page 2 (more complex and intermediate page)
    in this page 2 more information is asked to the user and there is a button TWO that call the method2 of the same servlet
    the final page (3) is generated by the servlet.
    So i success in the generation of the page 2 but when i click on the button TWO the controler (urlAction) send me null !!
    the call to the servlet is not done !
    some code:
    the servlet :
    public class ServletFichePrlvLEGactual extends HttpServlet{
         private String urlErreurs = null;
         private ArrayList erreursInitialisation = new ArrayList<String>();
         private String[] param�tres = {"urlFormulaire", "urlControleur","urlReponse","urlErreurs","urlReponseBis"};
         private Map params = new HashMap<String, String>();
         private ResultSet resultSetIDPrelevement;
    //     init
         @SuppressWarnings("unchecked")
         public void init() throws ServletException {
              // on r�cup�re les param�tres d'initialisation de la servlet
              ServletConfig config = getServletConfig();
              // on traite les autres param�tres d'initialisation
              String valeur = null;
              for (int i = 0; i < param�tres.length; i++) {
                   // valeur du param�tre
                   valeur = config.getInitParameter(param�tres);
                   // param�tre pr�sent ?
                   if (valeur == null) {
                        // on note l'erreur
                        erreursInitialisation.add("Le param�tre [" + param�tres[i] + "] n'a pas �t� initialis�");
                   } else {
                        // on m�morise la valeur du param�tre
                        params.put(param�tres[i], valeur);
                   // l'url de la vue [erreurs] a un traitement particulier
                   urlErreurs = config.getInitParameter("urlErreurs");
                   if (urlErreurs == null) {
                        throw new ServletException(
                        "Le param�tre [urlErreurs] n'a pas �t� initialis�");
         @SuppressWarnings("unchecked")
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // on v�rifie comment s'est pass�e l'initialisation de la servlet
              if (erreursInitialisation.size() != 0) {
                   // on passe la main � la page d'erreurs
                   request.setAttribute("erreurs", erreursInitialisation);
                   getServletContext().getRequestDispatcher(urlErreurs).forward(
                             request, response);
                   // fin
                   return;
              // on r�cup�re la m�thode d'envoi de la requ�te
              String m�thode = request.getMethod().toLowerCase();
              // on r�cup�re l'action � ex�cuter
              String action = request.getParameter("action");
              // action ?
              if (action == null) {
                   action = "init";
              // ex�cution action
              if (m�thode.equals("get") && action.equals("init")) {
                   // d�marrage application
                   doInit(request, response);
                   return;
              if (m�thode.equals("post") && action.equals("valider")) {
                   try {
                        doInterrogationFormulaire(request, response);
                   } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   return;
              if (m�thode.equals("post") && action.equals("testAffichage")) {
                   // validation du formulaire de saisie
                   try {
                        dotestAffichage(request, response);
                   } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   return;
              // autres cas
              doInit(request, response);
         void doInit(HttpServletRequest request, HttpServletResponse response) throws ServletException,
         IOException {
    //          on r�cup�re la session de l'utilisateur
              HttpSession session = request.getSession(true);
              // on envoie le formulaire vide
              session.setAttribute("nomCentre", "");
              session.setAttribute("NEtude", "");
              request.setAttribute("urlAction", (String) params.get("urlControleur"));
              getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                        request, response);
              return;
         void doInterrogationFormulaire(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException, SQLException, Exception {
    //          on r�cup�re les param�tres
              String nomCentre = (String) request.getParameter("nomCentre");
              String NEtude = (String) request.getParameter("NEtude");
              //puis on le stocke dans la session
              HttpSession session = request.getSession(true);
              session.setAttribute("nomCentre", nomCentre);
              session.setAttribute("NEtude", NEtude);
              Connexion com = new Connexion();
              try{
                   String query="SELECT idEtabl FROM Etablissement WHERE NomEtabl='"+nomCentre+"'";
                   ResultSet idCentre = com.ConnectAndQuestion(query);
                   idCentre.first();
                   String resulstatId=idCentre.getString("idEtabl");
                   String queryidPrelevement="SELECT idPrelevement FROM Etabl_Prlvmt where NEtude='"+NEtude+"' AND idEtabl='"+resulstatId+"'";
                   resultSetIDPrelevement=com.ConnectAndQuestion(queryidPrelevement);
                   if(resultSetIDPrelevement.next()!=false){
                        resultSetIDPrelevement.beforeFirst();
                        request.setAttribute("resultSetIDPrelevement", resultSetIDPrelevement);
                        getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(
                                  request, response);
                        com.close();
                        return;
                   else {     
                        getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                                  request, response);
                        com.close();
                        return;
              catch(Exception ex) {
                   System.err.println("\n*** SQLException caught in main()");
                   getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                             request, response);
                   return;          
         void dotestAffichage(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException, SQLException, Exception {
    //          on r�cup�re les param�tres d'int�ret
              ResultSet resultSetIDPrelevement = (ResultSet) request.getAttribute("resultSetIDPrelevement");
              Connexion updatePrlvmt= new Connexion();
              try{     
                   //serveur,login,pwd,database
                   updatePrlvmt.loadDriverAndConnect("127.0.0.1","3306","root","root","");
                   int k=1;
                   while (resultSetIDPrelevement.next()){
                        String idPrelevement = resultSetIDPrelevement.getString("idPrelevement");               
                        if (request.getParameter("choix"+k) !="Vl"){                         
                             String champModalite=(String) request.getParameter("modalite"+k);
                             String champExutoire=(String) request.getParameter("exutoire"+k);
                             String queryUpdate="UPDATE PrelevLEG SET Modalite='"+champModalite +
                             "',Exutoire='"+champExutoire +
                             "',Temp='null',TempMax='null',Heure='null' WHERE idPrelevement='"+idPrelevement +
                             updatePrlvmt.execute(queryUpdate);
                             k++;
                        if (request.getParameter("choix"+k) !="Ef"){
                             String queryUpdate="DELETE FROM PrelevLEG where idPrelevement='"+idPrelevement +"'";
                             updatePrlvmt.execute(queryUpdate);
                             k++;
                   updatePrlvmt.close();
              }catch(Exception ex) {
                   System.err.println("\n*** SQLException caught in main()");     
              request.setAttribute("urlAction", (String) params.get("urlControleur"));
              getServletContext().getRequestDispatcher((String) params.get("urlReponseBis")).forward(request,
                        response);
              return;
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException {
              // on passe la main au GET
              doGet(request, response);
    the web.xml:<servlet>
         <servlet-name>FichePrlvLEGactual</servlet-name>
    <servlet-class>germande.LEG.ServletFichePrlvLEGactual</servlet-class>
         <init-param>
    <param-name>urlFormulaire</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/formInterrogationActualPrlvmtLEG.jsp</param-value>
    </init-param>
    <init-param>
    <param-name>urlErreurs</param-name>
    <param-value>/erreursRecap.biotech.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlReponse</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/formFichePrlvLEGactual.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlReponseBis</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/respFichePrlvLEGactual.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlControleur</param-name>
    <param-value>ServletFichePrlvLEGactual</param-value>
    </init-param>     
    </servlet>
    the first simple form:<%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%
    // on r�cup�re les param�tres
    String nomCentre = (String) session.getAttribute("nomCentre");
    String NEtude = (String)session.getAttribute("NEtude");
    String urlAction=(String)request.getAttribute("urlAction");
    %>
    <html>
    <head>
    <title>Fiche R&eacute;sultats Legionelles - formulaire</title>
    </head>
    <body>
    <center>
    <h2>Fiche R&eacute;sultats Legionelles - formulaire</h2>
    <hr>
    <form action="<%= urlAction %>" method="post">
    <table>
         <tr>
         <td>Nom du centre hospitalier: </td>
         <td><input name="nomCentre" value="<%=nomCentre%>" type="text" size="20"></td>
    </tr>
                   <tr>
                        <td>Code interne : </td>
                        <td><input name="NEtude" value="<%=NEtude%>" type="text" size="20"></td>
                   </tr>
              </table>
    <table>
    <tr>
         <td><input type="submit" name="action" value="valider"></td>
         <td><input type="reset" value="R&eacute;tablir"></td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>
    the page two:<%
    ResultSet resultSetIDPrelevement = (ResultSet) request.getAttribute("resultSetIDPrelevement");
    String nomCentre = (String) session.getAttribute("nomCentre");
    String NEtude = (String)session.getAttribute("NEtude");
    String urlAction=(String)request.getAttribute("urlAction");
    %>
    <% String[] listModalite= {"1erjet-HorsActivit&eacute;","1erjet-EnActivit&eacute;",
    "2iemejet-D&eacute;sinfection","2iemejet-Flambage","Ecoulement"};
    String [] CorrespModal={"1erjet-HorsActivite","1erjet-EnsActivite",
    "2iemejet-Desinfection","2iemejet-Flambage","Ecoulement"};
    String[] listExutoire={"Mitigeur","M&eacute;langeur","Robinet","Douchette",
    "Douche","Temporis&eacute;","Vanne"};
    String [] CorrespExu={"Mi","Me","Ro","Dt","Do","Tp","Va"};
    %>
    <html>
    <head>
    <title>Fiche pr&eacute;l&egrave;vement: Actualisation - formulaire</title>
    </head>
    <body>      
    <center>
    <form action="<%= urlAction %>" method="post">
         <img src="logoBiotech.jpg" align="left" alt="logo Biotech-Germande" width="5%"></img>
    <h2>Fiche pr&eacute;l&egrave;vement: Actualisation - formulaire</h2>
    <br>
    </center>
         <br><br>
    <table>
         <tr>
         <td>Nom du centre hospitalier: </td>
    <td><input name="nomCentre" value="<%=nomCentre %>" type="text" size="20"></td>
    </tr>
              <tr>
                   <td>Code interne : </td>
                   <td><input name="NEtude" value="<%= NEtude %> " type="text" size="20"></td>
              </tr>
         </table>
         <!-- TABLE CONCERNANT LES PRELEVEMENTS -->
    <table>
         <%
         int m=1;
    while (resultSetIDPrelevement.next()){
              String idPrelevement = resultSetIDPrelevement.getString("idPrelevement");
         String modalite="modalite"+m;
    String exutoire="exutoire"+m;
    String choix="choix"+m;
    %>                
              <tr>
                   <td><input name="idPrelevement" value="<%= idPrelevement %>" type="text" size="25"></td>
                   <td><input type="radio" name="<%=choix %>" value="Vl">Valider
                        <input type="radio" name="<%=choix %>" value="Ef">Effacer
                   </td>
                   <td><SELECT name="modalite" >     
              <% for (int i=0;i<listModalite.length;i++){ %>
                        <OPTION value="<%= CorrespModal[i] %>" ><%= listModalite[i] %></OPTION>
                   <% } %>                                                                                
                   </SELECT></td>
                   <td><SELECT name="exutoire" >     
                   <% for (int i=0;i<listExutoire.length;i++){ %>
                        <OPTION value="<%= CorrespExu[i] %>" ><%= listExutoire[i] %></OPTION>
                   <% } %>                                                                           
                   </SELECT></td>          
              </tr>
         <% m++;
         } %>          
    </table>
    <table>
         <tr>
         <td><input type="submit" name="action" value="testAffichage"></td>
         <td><input type="reset" value="R&eacute;tablir"></td>
    </tr>
         </table>
    </form>
    </body>
    </html>
    I really hope that i am enough clear !! Please , i really need help : why can't i recall the servlet ?? with this /null in my url ? why the urlAction in the page 2 (more complex ..) send null ?
    thanks in advance !                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    Hi Everybody !
    I have a big problem and i am front it since i am programming in servlet/jsp .
    The basic scheme in the tutorial is form.jsp => call and processing by the servlet => response.jsp .
    That i want to do is : simple form.jsp=> call and processing by the servlet (with method 1) => response1.jsp (which is a more complete form) => call and processing by the servlet (with method 2 which it is unlike method 1) => response2.jsp (final page).
    But i don't know how to do it : you don't understand with i want to make it ? so there is a simple example: a user want to know what he have eaten at a day:
    1)my first simple form.jsp: ask to the user his name and a date
    2)the response 1 and page 2 is return: it's a more complex and complete form (this page is well generate in my project )
    with this date and the name of the user, i question my database : "what this user have eaten at this date "?
    For example : at this date, he ate : chips at the aperitif and apple for dessert .
    The user must to complete the page 2 with more information (which have to be insert in the database):
    ex:
    had he ate this apple : in the kitchen, in the park, at his work ...?? (drop-down menu)
    had he ate this apple : baked, uncured ...?? (another drop-down menu)
    To resume: i want it's to recall the servlet with another button (with a name different in the servlet) to a specific method.
    in the first and simple form there is a button ONE that call the method1 of the servlet
    the servlet generate the page 2 (more complex and intermediate page)
    in this page 2 more information is asked to the user and there is a button TWO that call the method2 of the same servlet
    the final page (3) is generated by the servlet.
    So i success in the generation of the page 2 but when i click on the button TWO the controler (urlAction) send me null !!
    the call to the servlet is not done !
    some code:
    the servlet :
    public class ServletFichePrlvLEGactual extends HttpServlet{
         private String urlErreurs = null;
         private ArrayList erreursInitialisation = new ArrayList<String>();
         private String[] param�tres = {"urlFormulaire", "urlControleur","urlReponse","urlErreurs","urlReponseBis"};
         private Map params = new HashMap<String, String>();
         private ResultSet resultSetIDPrelevement;
    //     init
         @SuppressWarnings("unchecked")
         public void init() throws ServletException {
              // on r�cup�re les param�tres d'initialisation de la servlet
              ServletConfig config = getServletConfig();
              // on traite les autres param�tres d'initialisation
              String valeur = null;
              for (int i = 0; i < param�tres.length; i++) {
                   // valeur du param�tre
                   valeur = config.getInitParameter(param�tres);
                   // param�tre pr�sent ?
                   if (valeur == null) {
                        // on note l'erreur
                        erreursInitialisation.add("Le param�tre [" + param�tres[i] + "] n'a pas �t� initialis�");
                   } else {
                        // on m�morise la valeur du param�tre
                        params.put(param�tres[i], valeur);
                   // l'url de la vue [erreurs] a un traitement particulier
                   urlErreurs = config.getInitParameter("urlErreurs");
                   if (urlErreurs == null) {
                        throw new ServletException(
                        "Le param�tre [urlErreurs] n'a pas �t� initialis�");
         @SuppressWarnings("unchecked")
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // on v�rifie comment s'est pass�e l'initialisation de la servlet
              if (erreursInitialisation.size() != 0) {
                   // on passe la main � la page d'erreurs
                   request.setAttribute("erreurs", erreursInitialisation);
                   getServletContext().getRequestDispatcher(urlErreurs).forward(
                             request, response);
                   // fin
                   return;
              // on r�cup�re la m�thode d'envoi de la requ�te
              String m�thode = request.getMethod().toLowerCase();
              // on r�cup�re l'action � ex�cuter
              String action = request.getParameter("action");
              // action ?
              if (action == null) {
                   action = "init";
              // ex�cution action
              if (m�thode.equals("get") && action.equals("init")) {
                   // d�marrage application
                   doInit(request, response);
                   return;
              if (m�thode.equals("post") && action.equals("valider")) {
                   try {
                        doInterrogationFormulaire(request, response);
                   } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   return;
              if (m�thode.equals("post") && action.equals("testAffichage")) {
                   // validation du formulaire de saisie
                   try {
                        dotestAffichage(request, response);
                   } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   return;
              // autres cas
              doInit(request, response);
         void doInit(HttpServletRequest request, HttpServletResponse response) throws ServletException,
         IOException {
    //          on r�cup�re la session de l'utilisateur
              HttpSession session = request.getSession(true);
              // on envoie le formulaire vide
              session.setAttribute("nomCentre", "");
              session.setAttribute("NEtude", "");
              request.setAttribute("urlAction", (String) params.get("urlControleur"));
              getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                        request, response);
              return;
         void doInterrogationFormulaire(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException, SQLException, Exception {
    //          on r�cup�re les param�tres
              String nomCentre = (String) request.getParameter("nomCentre");
              String NEtude = (String) request.getParameter("NEtude");
              //puis on le stocke dans la session
              HttpSession session = request.getSession(true);
              session.setAttribute("nomCentre", nomCentre);
              session.setAttribute("NEtude", NEtude);
              Connexion com = new Connexion();
              try{
                   String query="SELECT idEtabl FROM Etablissement WHERE NomEtabl='"+nomCentre+"'";
                   ResultSet idCentre = com.ConnectAndQuestion(query);
                   idCentre.first();
                   String resulstatId=idCentre.getString("idEtabl");
                   String queryidPrelevement="SELECT idPrelevement FROM Etabl_Prlvmt where NEtude='"+NEtude+"' AND idEtabl='"+resulstatId+"'";
                   resultSetIDPrelevement=com.ConnectAndQuestion(queryidPrelevement);
                   if(resultSetIDPrelevement.next()!=false){
                        resultSetIDPrelevement.beforeFirst();
                        request.setAttribute("resultSetIDPrelevement", resultSetIDPrelevement);
                        getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(
                                  request, response);
                        com.close();
                        return;
                   else {     
                        getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                                  request, response);
                        com.close();
                        return;
              catch(Exception ex) {
                   System.err.println("\n*** SQLException caught in main()");
                   getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
                             request, response);
                   return;          
         void dotestAffichage(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException, SQLException, Exception {
    //          on r�cup�re les param�tres d'int�ret
              ResultSet resultSetIDPrelevement = (ResultSet) request.getAttribute("resultSetIDPrelevement");
              Connexion updatePrlvmt= new Connexion();
              try{     
                   //serveur,login,pwd,database
                   updatePrlvmt.loadDriverAndConnect("127.0.0.1","3306","root","root","");
                   int k=1;
                   while (resultSetIDPrelevement.next()){
                        String idPrelevement = resultSetIDPrelevement.getString("idPrelevement");               
                        if (request.getParameter("choix"+k) !="Vl"){                         
                             String champModalite=(String) request.getParameter("modalite"+k);
                             String champExutoire=(String) request.getParameter("exutoire"+k);
                             String queryUpdate="UPDATE PrelevLEG SET Modalite='"+champModalite +
                             "',Exutoire='"+champExutoire +
                             "',Temp='null',TempMax='null',Heure='null' WHERE idPrelevement='"+idPrelevement +
                             updatePrlvmt.execute(queryUpdate);
                             k++;
                        if (request.getParameter("choix"+k) !="Ef"){
                             String queryUpdate="DELETE FROM PrelevLEG where idPrelevement='"+idPrelevement +"'";
                             updatePrlvmt.execute(queryUpdate);
                             k++;
                   updatePrlvmt.close();
              }catch(Exception ex) {
                   System.err.println("\n*** SQLException caught in main()");     
              request.setAttribute("urlAction", (String) params.get("urlControleur"));
              getServletContext().getRequestDispatcher((String) params.get("urlReponseBis")).forward(request,
                        response);
              return;
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException {
              // on passe la main au GET
              doGet(request, response);
    the web.xml:<servlet>
         <servlet-name>FichePrlvLEGactual</servlet-name>
    <servlet-class>germande.LEG.ServletFichePrlvLEGactual</servlet-class>
         <init-param>
    <param-name>urlFormulaire</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/formInterrogationActualPrlvmtLEG.jsp</param-value>
    </init-param>
    <init-param>
    <param-name>urlErreurs</param-name>
    <param-value>/erreursRecap.biotech.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlReponse</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/formFichePrlvLEGactual.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlReponseBis</param-name>
    <param-value>/WEB-INF/JSP/LEG/Prlvmnt/respFichePrlvLEGactual.jsp</param-value>
    </init-param>
         <init-param>
    <param-name>urlControleur</param-name>
    <param-value>ServletFichePrlvLEGactual</param-value>
    </init-param>     
    </servlet>
    the first simple form:<%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%
    // on r�cup�re les param�tres
    String nomCentre = (String) session.getAttribute("nomCentre");
    String NEtude = (String)session.getAttribute("NEtude");
    String urlAction=(String)request.getAttribute("urlAction");
    %>
    <html>
    <head>
    <title>Fiche R&eacute;sultats Legionelles - formulaire</title>
    </head>
    <body>
    <center>
    <h2>Fiche R&eacute;sultats Legionelles - formulaire</h2>
    <hr>
    <form action="<%= urlAction %>" method="post">
    <table>
         <tr>
         <td>Nom du centre hospitalier: </td>
         <td><input name="nomCentre" value="<%=nomCentre%>" type="text" size="20"></td>
    </tr>
                   <tr>
                        <td>Code interne : </td>
                        <td><input name="NEtude" value="<%=NEtude%>" type="text" size="20"></td>
                   </tr>
              </table>
    <table>
    <tr>
         <td><input type="submit" name="action" value="valider"></td>
         <td><input type="reset" value="R&eacute;tablir"></td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>
    the page two:<%
    ResultSet resultSetIDPrelevement = (ResultSet) request.getAttribute("resultSetIDPrelevement");
    String nomCentre = (String) session.getAttribute("nomCentre");
    String NEtude = (String)session.getAttribute("NEtude");
    String urlAction=(String)request.getAttribute("urlAction");
    %>
    <% String[] listModalite= {"1erjet-HorsActivit&eacute;","1erjet-EnActivit&eacute;",
    "2iemejet-D&eacute;sinfection","2iemejet-Flambage","Ecoulement"};
    String [] CorrespModal={"1erjet-HorsActivite","1erjet-EnsActivite",
    "2iemejet-Desinfection","2iemejet-Flambage","Ecoulement"};
    String[] listExutoire={"Mitigeur","M&eacute;langeur","Robinet","Douchette",
    "Douche","Temporis&eacute;","Vanne"};
    String [] CorrespExu={"Mi","Me","Ro","Dt","Do","Tp","Va"};
    %>
    <html>
    <head>
    <title>Fiche pr&eacute;l&egrave;vement: Actualisation - formulaire</title>
    </head>
    <body>      
    <center>
    <form action="<%= urlAction %>" method="post">
         <img src="logoBiotech.jpg" align="left" alt="logo Biotech-Germande" width="5%"></img>
    <h2>Fiche pr&eacute;l&egrave;vement: Actualisation - formulaire</h2>
    <br>
    </center>
         <br><br>
    <table>
         <tr>
         <td>Nom du centre hospitalier: </td>
    <td><input name="nomCentre" value="<%=nomCentre %>" type="text" size="20"></td>
    </tr>
              <tr>
                   <td>Code interne : </td>
                   <td><input name="NEtude" value="<%= NEtude %> " type="text" size="20"></td>
              </tr>
         </table>
         <!-- TABLE CONCERNANT LES PRELEVEMENTS -->
    <table>
         <%
         int m=1;
    while (resultSetIDPrelevement.next()){
              String idPrelevement = resultSetIDPrelevement.getString("idPrelevement");
         String modalite="modalite"+m;
    String exutoire="exutoire"+m;
    String choix="choix"+m;
    %>                
              <tr>
                   <td><input name="idPrelevement" value="<%= idPrelevement %>" type="text" size="25"></td>
                   <td><input type="radio" name="<%=choix %>" value="Vl">Valider
                        <input type="radio" name="<%=choix %>" value="Ef">Effacer
                   </td>
                   <td><SELECT name="modalite" >     
              <% for (int i=0;i<listModalite.length;i++){ %>
                        <OPTION value="<%= CorrespModal[i] %>" ><%= listModalite[i] %></OPTION>
                   <% } %>                                                                                
                   </SELECT></td>
                   <td><SELECT name="exutoire" >     
                   <% for (int i=0;i<listExutoire.length;i++){ %>
                        <OPTION value="<%= CorrespExu[i] %>" ><%= listExutoire[i] %></OPTION>
                   <% } %>                                                                           
                   </SELECT></td>          
              </tr>
         <% m++;
         } %>          
    </table>
    <table>
         <tr>
         <td><input type="submit" name="action" value="testAffichage"></td>
         <td><input type="reset" value="R&eacute;tablir"></td>
    </tr>
         </table>
    </form>
    </body>
    </html>
    I really hope that i am enough clear !! Please , i really need help : why can't i recall the servlet ?? with this /null in my url ? why the urlAction in the page 2 (more complex ..) send null ?
    thanks in advance !                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

  • NetBeans problem: Issue with servlets and Chinese character encoding

    Java Version: JDK1.5.0_01, JRE1.5.0_01 (International version)
    Netbeans Version: Netbeans IDE 4.0
    OS: Windows XP Personal Edition
    Dear Sirs,
    First at all thanks for reading this post. I am having the following issue. I am creating an application using html pages and servlets. I am using Chinese and English languages on them (html encoding UTF-8).
    I created a project in Netbeans and added an idex.html screen reporting to a servlet. Both index.html and in the servlet generated html page contains the line:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    Additional, I setup the character code settings in Netbeans:
    (tools-options-Java sources-Expert-default encoding=UTF-8
    When I run the project, index.html displays itself perfectly, with the Chinese characters displayed properly. The problem comes when the html created servlet is displayed, which instead of the Chinese characters some strange characters are displayed (�� instead of Chinese).
    I have tried different encodings from http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html without any luck. I also setup the encoding of the file itself (using right click-properties in the project menu of Netbeans).
    Also, when I am editing the servlet, the characters are displayed properly. I type them directly without any issue, but then the display is wrong at runtime.
    Also, just in case this have something to do with the problem, my PC was bought in US, therefore the default character set is not Chinese. I had to install the Chinese typing stuff later on. But like I said earlier, the html page is displayed properly, so I really think is some problem with Netbeans.
    After a week trying to find a solution, I decided to post it here in the hopes that someone will show me the way of the light.
    Thanks in advance for any ideas or help provided
    Aral.

    Ok, I found out some problems with Netbeans as well.
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response)
            throws IOException, ServletException
            response.setCharacterEncoding("UTF-8");
            request.setCharacterEncoding("UTF-8");
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            byte[] st = {-25,-75,-124,-27,-100,-106,-17,-68,-102,-27,-80,-113,-27,-72,-125,-26,-118,-75,-26,-105,-91,-27,-82,-93};
            out.println("this works: ");
            out.println(new String(st,"UTF-8"));
            out.println("<br>");
            out.println("this doesn't: ");
            out.println("some chinese copied from the Internet<br>");Right click the .java file and choose properties -> encoding UTF-8
    Then I make a copy of the .java file, rename it to html and open it with IE sure enough
    the Chinise is allready unreadable (not it's still readable in the IDE);
    When I compile the file with F9 I get the following error:
    whatever.java:101: warning: unmappable character for encoding Cp1252
    Tried to set the encoding to UNICODE but then the file doesn't compile.
    I gues you have to download the Japanese version for it to work correctly.

  • Netbeans Issue: Servlet do not display Chinese UTF-8 properly

    Netbeans Issue: Servlet do not display Chinese UTF-8 properly
    Java Version: JDK1.5.0_01, JRE1.5.0_01 (International version)
    Netbeans Version: Netbeans IDE 4.0
    OS: Windows XP Personal Edition
    Dear Sirs,
    First at all thanks for reading this post. I am having the following issue. I am creating an application using html pages and servlets. I am using Chinese and English languages on them (html encoding UTF-8).
    I created a project in Netbeans and added an idex.html screen reporting to a servlet. Both index.html and in the servlet generated html page contains the line:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    Additional, I setup the character code settings in Netbeans:
    (tools-options-Java sources-Expert-default encoding=UTF-8
    When I run the project, index.html displays itself perfectly, with the Chinese characters displayed properly. The problem comes when the html created servlet is displayed, which instead of the Chinese characters some strange characters are displayed (�� instead of Chinese).
    I have tried different encodings from http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html without any luck. I also setup the encoding of the file itself (using right click-properties in the project menu of Netbeans).
    Also, when I am editing the servlet, the characters are displayed properly. I type them directly without any issue, but then the display is wrong at runtime.
    Also, just in case this have something to do with the problem, my PC was bought in US, therefore the default character set is not Chinese. I had to install the Chinese typing stuff later on. But like I said earlier, the html page is displayed properly, so I really think is some problem with Netbeans.
    After a week trying to find a solution, I decided to post it here in the hopes that someone will show me the way of the light.
    Thanks in advance for any ideas or help provided
    Aral.

    Hi, thanks for your help. However I think the problem his more complex than it seems. Here is my doPost method (the important parts anyway):
    response.setCharacterEncoding("UTF-8"); //Not necessary because the next line should take care of it, but anyways...
    response.setContentType("text/html; charset=UTF-8; pageEncoding=UTF-8");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<meta http-equiv='Content-Language' content='en-us'>");
    out.println("<meta http-equiv='Content-Type' content='text/html; charset=utf-8; pageEncoding=utf-8'>"); //Again not necessary line, but anyways
    out.println("<title>Servlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("this is a test &#20320;&#22909; this is a test");
    out.println("</body>");
    out.println("</html>");
    out.close();
    This servlet is called from a html file. Also, when I load this in the browser, I right click on the screen and I can see that UTF-8 is setup allright. Doing some detective job I found that:
    - If the editor displays the characters perfectly and...
    - Other html pages (no servlets) in the same application can display chinese characters well and...
    - I have configured the encoding as UTF-8 in the servlet properties and in general properties and...
    - The file "web.xml" contains the encoding UTF-8 in its first line then...
    ...my only guess is that something goes wrong during the building of the project itself (ant?). Unfortunately I have no idea about configuring ant to that level, but I began to think that the problem may be there, during the compilation...
    Any ideas?
    Once more, thanks for any help or advice provided.
    Aral.

  • Applet in a servlet

    I have an applet class in my webserver directory. How do i call it within a servlet .What should be the values for code and codebase properties. Kindly send me an example code if possible.
    Bye for now
    Thanx in advance
    Naveen

    You don't call an applet from a servlet. But if you want to include the applet in the HTML generated by the servlet, there are no special rules that apply because a servlet generated the HTML. Just follow the usual rules for applets embedded in HTML.

  • Problem with servlet call within servlet

    I have already a servlet that generates a jpeg images that works fine.
    a second servlet generates an pdf document via the iText library and works also fine.
    the problem or question is how to call the first servlet to insert an
    image into the generated pdf??
    tia
    marky

    Have a look to HttpURLConnection object (in java.net package). A example of the code :
    URL url = "http://myServer/myJpegServlet";
    HttpURLConnection uc = (HttpURLConnection) url.openConnection();
    uc.setDoInput(true);
    uc.setUseCaches(false);
    uc.setAllowUserInteraction(false);
    InputStream dataIn = uc.getInputStream();
    byte[] buf = new byte[512];
    while( (dataIn.read(buf)) != -1 ) {
    //Do what you want with the data
    datain.close();
    uc.close;
    Hope this helps!
    Simon Pierre NOLIN

  • Servlets: Scrolling a html page

    I have a servlet that generates a page with edit buttons,
    rows, columns etc. When the edit button is pressed it
    allows the current row to be edited (hence the name edit button ;). The problem is, when I press a button way down on the bottom of the page (scrollable) it works as it should (opens a html textfield(?) on the row) but the drawback is, that the page is hiked up and you have to scroll down and find the edit row. So is there a way I can scroll it down automatically near the edit row?
    Thank you

    Have I understod correctly?
    When you press the button the servlet generates a new page with the textfield.
    You call the servlet something like this in the button: www.site.com/servlet/theServlet.
    Then call it as www.site.com/servlet/theServlet#here and insert <a name="here"> before the textfield in the generated page (in the servlet code).

Maybe you are looking for

  • New to BT, Speed and Stability Issues

    Hiya, I've been on BT Unlimited Broadband for just over 2 weeks now. I have a few problems, it seems: 1. Gigabit port just doesn't seem to work. I've searched this one and I do have a HH3 Type A. It works on the occasional restart, but then stops...

  • Strange behavior in OM (PI 7.4)

    Hi all! I have strange problem with my Operation Mapping in PI 7.4 In this OM i have two mappings. 1. Message Mapping, that sort message 2. Java Mapping, that make structure changes. When i test 1-1 step, copy result of this step and test 2-2 step in

  • Synchronous Proxy - SOAP Scenario (Error 500 in Response).

    Hi I've built a few Synchronous Proxy -> SOAP Scenarios, with 'Do Not Use SOAP Envelope' option. For two of them, I'm facing a common error. The error is: ADAPTER.HTTP_EXCEPTION (HTTP 500 Internal Server Error). When I paste the EXACTLY SAME payload

  • Error in-app purchase

    I cannot buy any in app stuff anymore!! It is from yesterday. I have tried anything! I can buy from the app store but not from apps? What can i do, and how can i solve it? Did: Iphone on/off Reset Log in log on account? New password on account! Every

  • How do I unblock someone from my contacts that I deleted but put their number back in my contacts?

    I need help!