33

I've been following the Google App Engine tutorials, and I'm having a problem with the .jsp file. Here is the code from Google: Using JSPs. I'm using Eclipse to build my project, and for some reason when I add the guestbook.jsp file to the war directory, it instantly gets a red error icon. I can't double click to open guestbook.jsp either. What could be going on here? enter image description here

Nifle
  • 11,745
  • 10
  • 75
  • 100
Petwoip
  • 1,365
  • 2
  • 17
  • 25
  • What are the error messages? Does this only happen after you've built the WAR file? If you're somehow trying to open the JSP from inside the WAR file you might run into trouble. – Michael Jun 25 '10 at 03:04
  • 1
    Strangely, there are no error messages. All I see is the red error icon next to the file name. Also, this red error icon comes immediately after I create the file. I can make any other file inside the war directory, but for some reason the .jsp doesn't work. – Petwoip Jun 25 '10 at 13:27
  • When you deploy your application using the WAR file, can you access the guestbook.jsp page? Does it add guestbook.jsp to the WAR? – Michael Jun 25 '10 at 14:02
  • @Nifle Did you add that screenshot? The OP said he can't open guestbook.jsp, but in the screenshot I see that it's open? What errors are listed in the "Problems" view in Eclipse? – Michael Jul 01 '10 at 02:03
  • @mangst - Found more info under a tab named Markers. *Your project must be configured to use a JDK in order to use JSPs guestbook.jsp* – Nifle Jul 01 '10 at 08:47
  • The error message I found lead me to the solution – Nifle Jul 01 '10 at 08:58
  • 1
    Lack of a JDK would cause problems for sure, haha. Although, Eclipse contains its own Java compiler, so for many basic tasks you only need a JRE. Glad you could fix it. – Michael Jul 01 '10 at 14:06

7 Answers7

65

In the end I seem to have wasted my bounty as I found the solution (with a little help) myself.

The problem arose because I was unfamiliar with Eclipse. When I found the more verbose error message Your project must be configured to use a JDK in order to use JSPs guestbook.jsp. It was located in a tab called 'Markers' in pane found at the bottom of the Eclipse window. enter image description here It seems that Eclipse wasn't aware that I had installed the JDK.

In Eclipse I went to menu Window->Preferences->Java->Installed JREs . Eclipse had only one entry there named jre6 I clicked the Add... button Chose Standard VM and browsed to the base directory of the jdk (in my case C:\Program Files\Java\jdk1.6.0_20)

I rebuilt my project but the same error was there. I had forgotten to check the box that tells Eclipse to use the jdk instead of the jre. enter image description here

As soon as I did that Eclipse rebuilt my project and the error was gone.

Nifle
  • 11,745
  • 10
  • 75
  • 100
  • in my Java folder only jre1.6.0_05 folder is there how can I install jdk in that folder ?? – Chirag Patel Mar 12 '12 at 17:40
  • 3
    In Eclipse 4.2, by ticking the Installed JREs `jdk1.6.0.xx` doesn't auto-refresh the specific gae project to use new settings. In my case, I also need alter Project Properties - Project Facets - Runtimes and tick `jdk1.6.0.xx` here in order to solve `Your project must be configuraed to use a JDK in order to use JSPs` error. – yorkw Jan 08 '13 at 03:51
3

Buddy

It'simple just select project->rightclick->properties->java Build path->select your jre->edit->alternate jre->select your jdk there.

So simple right.

One more thing that you have to do is to change is (Project facet) select perhaps it will ask for apply then apply if it didn't then change java level(check box) to 1.6 or 1.7 the jdk you have selected.

cheers.... Parveen Verma

Parveen
  • 31
  • 2
2

If you haven't gotten it to work yet, try launching Eclipse with this command:

eclipse.exe -vm C:\Program Files\Java\\bin\javaw.exe

This will launch Eclipse on the JDK. I use Windows 8 and JDK 1.6, and for me, it's necessary.

Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
mcbjam
  • 7,344
  • 10
  • 32
  • 40
2

3 Suggestions:

  1. Do a project-->Clean
  2. Make sure you have this in web.xml:

    <welcome-file-list> <welcome-file>guestbook.jsp</welcome-file> </welcome-file-list>

  3. Have Project-->Build Automatically enabled, I deployed a Java app on AppEngine long time back and I see a classes folder in the WB-INF folder which has the class of the servlet and the META-INF folder.

zengr
  • 38,346
  • 37
  • 130
  • 192
1

Eclipse wasn't aware that you have installed the JDK.

So In Eclipse go to menu Window->Preferences->Java->Installed JREs . Eclipse has only one entry-jre6 click the Add button Choose Standard VM and browse to the base directory of the jdk (in my case C:\Program Files\Java\jdk1.7.0_45)

In my case these steps not enough, still i had error.

So I included these steps too.

Step 1: I copied the jdk1.7.0_45 folder from program files, and pasted it in to my workspace (D:\workspace) and Renamed the folder jdk1.7.0_45 to JDK inside the workspace.

Step 2: And added these lines

-vm
C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe

At the beginning of the eclipse.ini file. This file will be inside your eclipse folder. The type of file is: Configuration settings (.ini) (Note: Add these lines, Other than this don't change anything in this file)

After these steps my error was gone.

Sufiyan Ghori
  • 18,164
  • 14
  • 82
  • 110
Suganya Karthik
  • 131
  • 1
  • 1
  • 9
0

Even after all these other techniques failed (include <%@ taglib prefix="fn" etc; ensure JRE is in project build path; ensure Eclipse Java preferences associate correct JRE with compatible Execution Environment; import jstl-1.2.jar into project and add to project Build Path JARs)... I restarted Eclipse and all was well. Except my decreasing respect for Eclipse's overall integrity.

Matthew
  • 757
  • 11
  • 19
0

I just cannot believe what happened. All the time I had one row that was something like : 1 open-jdk-7 and one row on second place 2 oracle-jdk-7 The second row was selected the whole time, I restarted, tried to uncheck and check again. Tried every possible combination. In the moment I deleted the first row the things are fixed :). Crazy huh

makkasi
  • 6,328
  • 4
  • 45
  • 60