Link to home
Start Free TrialLog in
Avatar of prsubject
prsubjectFlag for India

asked on

Valid format of <OPTION <%= range.equalsIgnoreCase(" ") ? "selected" : "" %> > </OPTION>

I am having a jsp page with option tag as below which is not being recognised. Could someone give an alternative to the below statement, as an option tag only.

<OPTION <%= range.equalsIgnoreCase("Yesterday") ? "selected" : "" %>>Yesterday</OPTION>
Avatar of prsubject
prsubject
Flag of India image

ASKER

I am getting the error option tag not closed. I have even turned off the validators of jsp in eclipse. This is the only error that is being shown and is stopping me from deploying the war file on oracle weblogic.
This is what I have

            <SELECT NAME="range" onChange="javascript:setDateRange()">
          <OPTION <%= range.equalsIgnoreCase(" ") ? "selected" : "" %> > </OPTION>
          <OPTION <%= range.equalsIgnoreCase("All Times") ? "selected" : "" %> >All Times</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Yesterday") ? "selected" : "" %>>Yesterday</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Today") ? "selected" : "" %>>Today</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Tomarrow") ? "selected" : "" %>>Tomorrow</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Last Week") ? "selected" : "" %>>Last Week</OPTION>
          <OPTION <%= range.equalsIgnoreCase("This Week") ? "selected" : "" %>>This Week</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Next Week") ? "selected" : "" %>>Next Week</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Last Month") ? "selected" : "" %>>Last Month</OPTION>
          <OPTION <%= range.equalsIgnoreCase("This Month") ? "selected" : "" %>>This Month</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Next Month") ? "selected" : "" %>>Next Month</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Last Qtr") ? "selected" : "" %>>Last Qtr</OPTION>
          <OPTION <%= range.equalsIgnoreCase("This Qtr") ? "selected" : "" %>>This Qtr</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Next Qtr") ? "selected" : "" %>>Next Qtr</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Last Year") ? "selected" : "" %>>Last Year</OPTION>
          <OPTION <%= range.equalsIgnoreCase("This Year") ? "selected" : "" %>>This Year</OPTION>
          <OPTION <%= range.equalsIgnoreCase("Next Year") ? "selected" : "" %>>Next Year</OPTION>
        </SELECT>
This is the javascript

function setDateRange()
{
      // Note: Do not use endTime = startTime. This assigns startTime and EndTime
      // to the same object reference.

      // getDay() sun=0, mon=1, tue=2, wed=3, thur=4, fri=5, sat = 6

    var qtrStart = new Array
      (
        new Date(2099, 0, 1, 0, 0, 0, 0),
        new Date(2099, 3, 1, 0, 0, 0, 0),
        new Date(2099, 6, 1, 0, 0, 0, 0),
        new Date(2099, 9, 1, 0, 0, 0, 0)
      );

         var qtrEnd = new Array
      (
        new Date(2099, 2, 31, 23, 59, 59, 999),
        new Date(2099, 5, 30, 23, 59, 59, 999),
        new Date(2099, 8, 30, 23, 59, 59, 999),
        new Date(2099, 11, 31, 23, 59, 59, 999)
    );

      var range = getSelected(document.myForm.range);

    var startTime = new Date();
    var endTime   = new Date(startTime.getTime());

    if (range == "All Times")
    {
            startTime = new Date(document.myForm.startYear.options[0].text, 0, 1, 0, 0, 0, 0);
            endTime   = new Date(document.myForm.endYear.options[document.myForm.endYear.length-1].text, 11, 31, 23, 59, 59, 999);
      }
      else if (range == "Yesterday")
    {
            startTime.setDate(startTime.getDate() - 1);
            endTime.setTime(startTime.getTime());
    }
      else if (range == "Today")
    {
            // Nothing
      }
    else if (range == "Tomorrow")
    {
        startTime.setTime(startTime.getTime() + 24*60*60*1000);
          endTime.setTime(startTime.getTime());
    }
    else if (range == "Last Week")
    {
            startTime.setDate(startTime.getDate() - startTime.getDay() - 7);
                 endTime.setTime(startTime.getTime());
            endTime.setDate(startTime.getDate() + 6);
      }
    else if (range == "This Week")
    {
            startTime.setDate(startTime.getDate() - startTime.getDay());
            endTime.setTime(startTime.getTime());
            endTime.setDate(startTime.getDate() + 6);
    }
    else if (range == "Next Week")
    {
            startTime.setDate(startTime.getDate() - startTime.getDay() + 7);
                 endTime.setTime(startTime.getTime());
            endTime.setDate(startTime.getDate() + 6);
    }
    else if (range == "Last Month")
    {
            var month = startTime.getMonth() - 1
            new java.util.Date();
            startTime.setMonth(month, 1);
            new java.util.Date();
            endTime.setMonth(month, 31);
    }
    else if (range == "This Month")
    {
            startTime.setDate(1);
            endTime.setDate(31);
    }
    else if (range == "Next Month")
    {
            var month = startTime.getMonth() + 1
            startTime.setMonth(month, 1);
            endTime.setMonth(month, 31);
    }
    else if (range == "Last Year")
    {
            var year = startTime.getYear() + 1900 - 1
            startTime.setMonth(0, 1);
            startTime.setYear(year);
            endTime.setMonth(11, 31);
            endTime.setYear(year);
    }
    else if (range == "This Year")
    {
            startTime.setMonth(0, 1)
            endTime.setMonth(11, 31)
    }
    else if (range == "Next Year")
    {
            var year = startTime.getYear() + 1900 + 1
            startTime.setMonth(0, 1);
            startTime.setYear(year);
            endTime.setMonth(11, 31);
            endTime.setYear(year);
    }
    else if (range == "Last Qtr")
    {
            var qtr = Math.floor(startTime.getMonth() / 3);
            qtr = qtr - 1;

            var year = startTime.getYear() + 1900;
            if (qtr <= 0 )
            {
                  qtr = 3;
                  year = year - 1;
            }

            startTime.setTime(qtrStart[qtr].getTime());
            startTime.setYear(year);

            endTime.setTime(qtrEnd[qtr].getTime());
            endTime.setYear(year);
      }
    else if (range == "This Qtr")
    {
            var qtr = Math.floor(startTime.getMonth() / 3);
            var year = startTime.getYear() + 1900;
            
            startTime.setTime(qtrStart[qtr].getTime());
            startTime.setYear(year);

            endTime.setTime(qtrEnd[qtr].getTime());
            endTime.setYear(year);
    }
    else if (range == "Next Qtr")
    {
            var qtr = Math.floor(startTime.getMonth() / 3);
            qtr = qtr + 1;

            var year = startTime.getYear() + 1900;
            if (qtr >= 3 )
            {
                  qtr = 0;
                  year = year + 1;
            }
            startTime.setTime(qtrStart[qtr].getTime());
            startTime.setYear(year);
            
            endTime.setTime(qtrEnd[qtr].getTime());
            endTime.setYear(year);
    }

      // Adjust times to start and end of day
      startTime.setHours(0);
      startTime.setMinutes(0);
      startTime.setSeconds(0);

      endTime.setHours(11);
      endTime.setMinutes(59);
      endTime.setSeconds(59);

      // Set the date fields in the form
      setSelect(document.myForm.startDay, startTime.getDate());
      setSelect(document.myForm.startMonth, startTime.getMonth()+1);
      setSelect(document.myForm.startYear, startTime.getFullYear());

      setSelect(document.myForm.endDay, endTime.getDate());
      setSelect(document.myForm.endMonth, endTime.getMonth()+1);
      setSelect(document.myForm.endYear, endTime.getFullYear());
}
Avatar of mrcoffee365
Again, I have no problem with this code, running in Tomcat5 or 6.

You say you are running this in eclipse, but your eventual server is weblogic.  Which one gives you the error?

Please post the full exception -- that might help track down the real problem.
Please ensure:
1) code is written in a JSP file
2) JSP file is deployed on a web server (tomcat, weblogic, websphere etc.)
3) JSP is being accessed from a web-browser.
The code is written in JSP file. The server that is giving the error is weblogic. It is not allowing me to deploy from eclipse environment. At the time I right click on the project and say publish it is not getting deployed saying the project contains errors and the error is Option tag not ended properly.
Okay -- please post the exception or error messages.   You say that weblogic is giving you the error, but you are actually seeing the error in the eclipse console, right?  Post that error message here.
Also - please post which versions of eclipse and weblogic you are using.  There seem to have been problems specifically with weblogic deployments because of non-standard jars in weblogic.
I am using eclipse helio.
The error message
Error(s) found in module 'NewDirAdmin'. Publish was cancelled. See "Problems" view for details.
Start tag (<OPTION>) not closed. at DateRange.inc --> DateRange.inc is the name of the file which contains this option tag
Start tag (<OPTION>) not closed. at DateRange.inc
Start tag (<OPTION>) not closed. at DateRange.inc


Nothing is being displayed on the console.

The Markers tab on Eclipse says.

Description      Resource      Path      Location      Type
Start tag (<OPTION>) not closed.      DateRange.inc      /NewDirAdmin/WebContent/includes      line 241      HTML Problem
I have removed all the jsp validations in eclipse IDE.
The weblogic version is 10gR3. It is actually Oracle Weblogic.
Help Please.
ASKER CERTIFIED SOLUTION
Avatar of mrcoffee365
mrcoffee365
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The error is gone. Real big thanks.
Something has gone wrong. I have accepted the answer given by mrcoffee365 and have even increased the points awarded fron 250 to 500. I need this points to be awarded to mrcoffee365.
I would like to ask a question out of curiosity. Why has the .inc file thrown errors.
I believe that it's a problem with Eclipse.  Eclipse is a great IDE, but for some reason they did a bad job with JSP file interpretation.  Eclipse insists on evaluating each included file as if it were an independent file, then putting them together into the whole JSP page.   So since the .inc file did not have the .jsp extension, it was evaluated as ... plain html?  I don't know what the  Eclipse default is, but it sounds as if it was evaluated as html.  When it didn't parse correctly as plain html, Eclipse gave you that error without combining the .inc into the final .jsp file and evaluating the final.

This problem is much worse with .jspf files, which are frequently not valid by themselves, but only when included into the outer .jsp files.

However, usually it's possible to refactor the component  .jsp files so that they pass evaluation with Eclipse and they can be included in the outer .jsp files.  Eclipse is a great IDE, but it has some quirks.
@prsubject,

I have already given you the accepted solution much more earlier in ID: 34162425 and could you please tell us why it was not accepted.

Regards
pramodkrjsr: Your response was not an answer.  You simply listed information which had already been mentioned in the question -- that this involved jsp pages, a web server, and a browser.
@mrcoffee365,
Yes, in the question it was told that the file is a JSP, but actually it was .inc

I suspected that there may be a chance that the file extension is not a JSP and suggested to re-check and you gave the same solution.

Regards
pramodkrjsr: You did not suggest that the problem was that there was an included .inc file.  And, that was not precisely the problem -- it was a quirk of Eclipse.

There is no problem with compiling jsp files which include files of any extension.