Solved

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

Posted on 2010-11-17
21
280 Views
Last Modified: 2012-05-10
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>
0
Comment
Question by:prsubject
  • 11
  • 7
  • 3
21 Comments
 

Author Comment

by:prsubject
ID: 34160241
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.
0
 

Author Comment

by:prsubject
ID: 34160262
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>
0
 

Author Comment

by:prsubject
ID: 34160275
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());
}
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 34161198
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.
0
 
LVL 10

Expert Comment

by:Pramod Kumar
ID: 34162425
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.
0
 

Author Comment

by:prsubject
ID: 34163575
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.
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 34164158
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.
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 34164285
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.
0
 

Author Comment

by:prsubject
ID: 34164746
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
0
 

Author Comment

by:prsubject
ID: 34164756
I have removed all the jsp validations in eclipse IDE.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:prsubject
ID: 34164886
The weblogic version is 10gR3. It is actually Oracle Weblogic.
0
 

Author Comment

by:prsubject
ID: 34165054
Help Please.
0
 
LVL 27

Accepted Solution

by:
mrcoffee365 earned 500 total points
ID: 34165760
Can you try changing the name of DateRange.inc to DateRange.jsp?  Make sure to change the include line in your outer jsp file to match the new name as well.

0
 

Author Comment

by:prsubject
ID: 34165849
The error is gone. Real big thanks.
0
 

Author Comment

by:prsubject
ID: 34165917
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.
0
 

Author Comment

by:prsubject
ID: 34165928
I would like to ask a question out of curiosity. Why has the .inc file thrown errors.
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 34167414
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.
0
 
LVL 10

Expert Comment

by:Pramod Kumar
ID: 34171173
@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
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 34173215
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.
0
 
LVL 10

Expert Comment

by:Pramod Kumar
ID: 34180639
@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
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 34181688
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.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now