39 users online (1 members and 38 guests)  


  Results 1 to 8 of 8

Related

  1. Multiple Popup windows    Forum: Javascript Forum
    Replies: 1
  2. Replies: 5
  3. refresh popup window using javascript    Forum: Javascript Forum
    Replies: 3
  4. multiple popup windows on one page    Forum: Javascript Forum
    Replies: 1
  5. popup help    Forum: HTML Forum
    Replies: 3
  1. #1
    Ishaaq
    Ishaaq's Avatar
    Guest

    Question javascript popup windows

    Hi all,
    I am having a problem with a bit of javascript on my page.

    The script opens a new window and writes html into it. The html consists of a form with a text input box and a submit button. This works fine. The user enters his values and they are passed back to my server (running a servlet). This too works fine.

    The problem is that if the user enters special characters not in the normal english character set (chars like ) they get garbled by the time it reaches my server. I have isolated the problem to such scripted forms on IE (Netscape and Opera work fine) only.

    If it were a normal form on a normal window the values don't get garbled. It's only under these unique conditions that it fails.

    Any ideas anyone??
    Thanks,
    Ishaaq

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Exclamation

    Would you mind either posting a link, or posting your script? Either will do.

    Cheers

    ------------------
    QuietDean- ]

  3. #3
    Ishaaq
    Ishaaq's Avatar
    Guest

    Post

    Ok, am appending the html at the end of this post. I've trimmed the code down to it's bare essentials rather than giving you a link that would contain a lot of non-essential stuff too.

    It will create a link that should pop up a new window when clicked - the new window will have a form. All you need to do is connect this to some servlet/CGI script to get the values from the form.

    I'm using a servlet to pick up the POST request. But as mentioned earlier - non-English characters like get garbled in the process. There is nothing wrong with the servlet itself - ordinary non-scripted forms work fine and even this script works fine on Netscape and Opera.

    Thanks for being willing to have a look.

    Regards,
    Ishaaq


    <html>
    <body>
    <SCRIPT>
    <!--
    var memTxt,memwin;
    function showForm()
    {
    var start = '<HTML>\n<BODY>';
    var form = '<FORM METHOD="POST" ACTION="http://192.168.170.20:8080/xw/xweb">';
    var body = '\n<INPUT NAME="txtbox" size="55">';
    body += '\n<INPUT TYPE="submit">\n</FORM>';
    var end = '\n</BODY>\n</HTML>';
    memwin = open('', 'memwin', 'toolbar=no,directories=no,menubar=no,width=420,height=170');
    memwin.document.write(start);
    memwin.document.write(form);
    memwin.document.write(body);
    memwin.document.write(end);
    memwin.document.close();
    }
    //-->
    </SCRIPT>
    <a href="javascript:showForm()" >test</a>
    </body></html>

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Unhappy

    Sorry mate,

    I cannot seem to reproduce this at all, and I have tried quite a few hosts/scripts combinations.

    Any more clues for us?

    ------------------
    QuietDean-

  5. #5
    Ishaaq
    Ishaaq's Avatar
    Guest
    Thanks for taking the trouble, also sorry I didn't reply sooner, I was out.

    My server application is a Java Servlet. Am appending a sample servlet at the end of this mail. I hope you're conversent with Java. Meanwhile I'll try and brush up on some CGI and see if the problem disappears for me there - if so then I guess it is a Java problem, though what suprises me is that normal - non-Javascript forms work fine as you will see if you are successful in compiling and deploying the servlet.

    Some details: using Tomcat 3.2.1 and IE5.0 (& 5.5 also).

    Thanks again,
    Ishaaq
    ---------------------------------------
    import java.io.*;
    import javax.servlet.http.*;
    public class TestServlet extends HttpServlet
    {
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException
    {
    StringBuffer sb=new StringBuffer("<HTML><BODY>");
    String input=req.getParameter("input");
    if(input!=null)
    sb.append("You entered the text: "+input)
    .append("<BR>");
    sb.append("</BODY><HTML>");
    Writer wr=res.getWriter();
    wr.write(sb.toString());
    }

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException
    {
    StringBuffer sb=new StringBuffer("<HTML><BODY>")
    .append("<a href=\"javascript:showForm()\">click me!</a>");
    insertJavaScriptForm(sb);
    insertNormalForm(sb);
    sb.append("</BODY></HTML>");
    Writer wr=res.getWriter();
    wr.write(sb.toString());
    }

    private void insertJavaScriptForm(StringBuffer sb)
    {
    sb.append("<SCRIPT>\n<!--")
    .append("var memTxt,memwin;\n")
    .append("function showForm(){\n")
    .append("var start = '<HTML>\\n<BODY>';\n")
    .append("var form = '<FORM METHOD=\"POST\" ACTION=\"TestServlet\">';\n")
    .append("var body = '\\n<INPUT NAME=\"input\" size=\"55\">';\n")
    .append("body += '\\n<INPUT TYPE=\"submit\">\\n</FORM>';\n")
    .append("var end = '\\n</BODY>\\n</HTML>';\n")
    .append("memwin = open('', 'memwin', 'toolbar=no,directories=no,menubar=no,width=420,height=170');\n")
    .append("memwin.document.write(start);\n")
    .append("memwin.document.write(form);\n")
    .append("memwin.document.write(body);\n")
    .append("memwin.document.write(end);\n")
    .append("memwin.document.close();\n")
    .append("}\n")
    .append("//-->\n")
    .append("</SCRIPT>\n");
    }

    private void insertNormalForm(StringBuffer sb)
    {
    sb.append("<FORM METHOD=\"POST\" ACTION=\"TestServlet\" TARGET=\"_blank\">")
    .append("<INPUT NAME=\"input\" size=\"55\">")
    .append("<INPUT TYPE=\"submit\"></FORM>");
    }
    }

  6. #6
    Ishaaq
    Ishaaq's Avatar
    Guest
    By the way I just checked - I get the same problem using Allaire's JRun3.1. So the problem does not lie in Tomcat. I doubt it lies with Java also since (as I mentioned earlier) the problem does not show up on Opera or Netscape.

    Regards,
    Ishaaq

  7. #7
    Ishaaq
    Ishaaq's Avatar
    Guest

    Unhappy

    Thanks anyway for your trouble, I appreciate it.

  8. #8
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Unhappy

    I'm not too hot on Java to be honest, more of a php man.

    Heres a useful JavaLink -
    http://java.sun.com/people/linden/faq_d.html#Java Gotcha's

    Whilst I agree that Java does not look the most likely suspect (The servlet is all server side I presume?) it might be worth looking into.

    I have played with CGI and PHP processing using every character I could think of, without reproducing. Hmm.

    Stumped, mate. Sorry.

    ------------------
    QuietDean-



Tags for this Thread