Web Analytics Made Easy -
StatCounter Jsp - CodingForum

Announcement

Collapse
No announcement yet.

Jsp

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jsp

    Hello,

    I'm using HTML to create a form. I use JSP to process it.
    eg:
    In html:
    Name:
    <input type="text" name="stu_name" and value="Name" size="15">

    In jsp:

    <% String name = rs.getParameter("stu_name"); %>

    Problem:

    When the user keys in any character with an apostrophe (') in the text box, there'll be an error!!! Why can't jsp process the apostrophe?

    Please help!!! Thanks...

  • #2
    I'm not a JSP coder but suspect that your problem is database-related rather than with the code itself: have a look at this thread regarding single-quotes in database fields:

    Comment


    • #3
      JSP

      Hello..


      I don't think so. I can enter data with apostrophe into the database in Mysql interface using:

      insert into person values ("Eagle's Nest");

      But I can't in JSP.

      when i enter Eagle's Nest in the text box, JSP will get that value using:

      <% String add= request.getParameter("add"); %>
      <% rs = st.executeQuery("select distinct add from PERSON where add like '%"+Eagle's Land+"%';");%>

      it will return an error saying unresolve sysmbol ( ' )!!!

      please help!!!

      Thanks again...

      Comment


      • #4
        Right, but if you looked at the string closely, you'd see in your JSP your actually running this SQL statement:

        Code:
        select distinct add from PERSON where add like '%Eagle's Land%';
        You'll need to escape the 2nd ' (the one at le's) with a backslash.
        Create accessible online surveys -::- Koobten.com - compare netbook prices and reviews -::- Affordable, reliable hosting for less than $20 per year
        Zend Certified Engineer

        Comment


        • #5
          JSP

          Hello...


          Yeah, thanks!!!

          I modified the codes to ""\+name+"\", and it worked!!!
          Thanks a lot!!!

          Comment


          • #6
            Why would anyone use JSP (this is a genuine question not slagging it off) when there's already ASP(.net) and PHP, not to mention CGI?

            Comment


            • #7
              Originally posted by d000hg
              Why would anyone use JSP (this is a genuine question not slagging it off) when there's already ASP(.net) and PHP, not to mention CGI?
              Not that I want to get all snotty about this, but have you considered the fact that sometimes your employer makes these decisions and you are simply stuck with the results (however bad they may be)?

              The place I work gave me a WIMP environment (Windos / IIS / MS SQL / PHP). I often post questions saying I'm using PHP with MS SQL nad the only response is "Why don't you use mySQL?". Well, it's because I don't have a choice.

              Sorry, don't mean to be rude, just pointing out a fact. Sometimes you don't have a choice on your projects.
              Create accessible online surveys -::- Koobten.com - compare netbook prices and reviews -::- Affordable, reliable hosting for less than $20 per year
              Zend Certified Engineer

              Comment


              • #8
                Fair point, I hadn't considered that. JSP seems like a reasonable alternative to ASP (similar except running in the java VM as I understand it). I'll rephrase: why would a company choose it? What purpose does it serve?
                Oh and by MS SQL do you mean access? And is IIS just the tool to let you test on a local machine without having to upload to the server?

                Comment


                • #9
                  IIS is a server, the same as apache is. MSSQL isn't the same as MS Access. The main difference is Access is a GUI development tool with an embedded database engine (Jet), when SQL Server is database engine, with no GUI development tool. Both have different data structures

                  Sometimes you find the manager or team leader for a company you work with will only offer you what he (or she) knows best. It's rare they'd allow you to use something in a completely different language to what everyone in the company is used to using. Would cost a bit more money to re-train all the company to learn another language, when everyone's already trained to use something else over the years.
                  Last edited by Nightfire; Mar 15, 2004, 11:01 AM.

                  Comment

                  Working...
                  X