jsp string syntax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • keydrive
    New Member
    • Oct 2007
    • 57

    jsp string syntax

    How to escape double quotes within a string to include the value of a variable from a JSP?

    Two variables, "start" and "end" are dates from a calendar function. I need the variable "query" to update with the start and end variables but can't get it to work.

    Code:
    String 	Start = request.getParameter("start");
    String 	End   = request.getParameter("end");
    
    
    if ((Start != null) && (!Start.equals("")) || ((End != null) && (!End.equals(""))))
    	{    
    	query += "+AND+NEAR{Start,End}:MODIFIED";
    	}

    I tried encoding the curly brackets because I need them in the output like %7B${start},${e nd}%7D but that doesn't work either. Also tried a variety of quotes.

    Thanks for your suggestions
  • keydrive
    New Member
    • Oct 2007
    • 57

    #2
    I understand how to return the value of a variable in JSP. I'm just having problems escaping the double quotes required on the query += line.

    Code:
    <%=Start%>

    Comment

    • keydrive
      New Member
      • Oct 2007
      • 57

      #3
      Solution:

      Code:
      query += "+AND+NEAR{" + Start + "," + End + "}:MODIFIED";

      Comment

      Working...