Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » New to JSP +
New to JSP + [message #223930] Tue, 18 November 2008 16:12 Go to next message
Chuck Moore is currently offline Chuck MooreFriend
Messages: 8
Registered: July 2009
Junior Member
I have a website already, it uses Tomcat, and I want to add some .jsp to
facilitate some simple dynamic content.
The production server does/will not have a JDK on it.
On my PC, I can run a sample .jsp, but the generated .java and .class are
placed in Tomcat's "work" directory.
I need to provide a .jar or .class file(s) to the production server so
that the .jsp will work.
I've learned about editing the web.xml file, but still no joy.
Now I'm trying to use Eclipse to create the .jsp and run the page, but no
joy there either. I know I'm probably missing a lot some where, but I'd
rather not spend months studying to figure out what I'm doing wrong.

From within Eclipse I can successfully run my index.html page which
creates three frames, and the title and footer seconds properly display
their .html content. Just the middle.jsp doesn't fly, and it currently as
simple "Hello World" thing.

I'm having some difficulty finding the right place for help.
Help?
Re: New to JSP + [message #223949 is a reply to message #223930] Tue, 18 November 2008 19:27 Go to previous messageGo to next message
Lawrence Mandel is currently offline Lawrence MandelFriend
Messages: 486
Registered: July 2009
Senior Member
If you're going to use JSPs Tomcat requires a JDK as your JSPs need to be
compiled into Java classes (specifically, servlets). Alternatively, you
can precompile your JSPs using Tomcat's JSPC [1].

[1] http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html#We b
Application Compilation

Lawrence
Re: New to JSP + [message #223956 is a reply to message #223930] Tue, 18 November 2008 19:41 Go to previous messageGo to next message
Chuck Moore is currently offline Chuck MooreFriend
Messages: 8
Registered: July 2009
Junior Member
I don't know what I did, but the .jsp page is now displaying properly.
But, I cannot seem to find the .class and .java files associated with it.
That is, the generated servlet app.
I set the output path, but nothing is showing up there, and I'm not
finding anything under the Tomcat webapps nor work directories.
Re: New to JSP + [message #223962 is a reply to message #223949] Tue, 18 November 2008 19:46 Go to previous messageGo to next message
Chuck Moore is currently offline Chuck MooreFriend
Messages: 8
Registered: July 2009
Junior Member
Yes, I found that out last week. That is why I downloaded JDK, ANT,
Tomcat and Eclipse to my workstation specifically to create the .java and
class files.

When I ran the webpage on Tomcat directly, it created the .java and .class
files in the Tomcat work directory, and everything seemed to function.
But, I would prefer to put the .class file in WEB-INF/classes or a .jar
file in WEB-INF/lib. I tried a simple manual method and it wasn't
working. So I assumed I was missing important pieces. So, I thought if I
created/ran the same thing within Eclipse, it would generate what I needed
and would build a complete .jar file for me. That doesn't seem to be
happening.
Re: New to JSP + [message #223969 is a reply to message #223949] Tue, 18 November 2008 20:32 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1313
Registered: July 2009
Senior Member
lmandel@ca.ibm.com wrote:
> If you're going to use JSPs Tomcat requires a JDK as your JSPs need to be
> compiled into Java classes (specifically, servlets).

Actually, Tomcat 5.5 and later include a copy of Eclipse's JDT compiler
and thus by default don't use the JDK's tools.jar. A JRE is sufficient
for these Tomcat versions.

Alternatively, you
> can precompile your JSPs using Tomcat's JSPC [1].
>
> [1] http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html#We b
> Application Compilation

Since the JSPC Ant script uses the javac task, a JDK would be required
for the script to run.

Cheers,
Larry

>
> Lawrence
Re: New to JSP + [message #223985 is a reply to message #223930] Tue, 18 November 2008 20:52 Go to previous messageGo to next message
Chuck Moore is currently offline Chuck MooreFriend
Messages: 8
Registered: July 2009
Junior Member
Well, I've got an ugly work around for now.

1) create the .jsp page and let Tomcat create the servlet.
2) create a normal java project
3) create a new class in the java project
4) paste the .java contents created by Tomcat into the new class file.
5) remove (or update) the generated package statement.
6) Save the class file, which causes an automatic build.
7) Copy the new class file to WEB-INF/classes.
8) make the appropriate <servlet> and <servlet-mapping> entries in web.xml

For play_middle.jsp, the generated .java and .class files are
play_middle_jsp

The web.xml servlet entries are then

<servlet>
<servlet-name>play_middle_jsp</servlet-name>
<servlet-class>play_middle_jsp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>play_middle_jsp</servlet-name>
<url-pattern>/Web/IT_Techs/play_middle.jsp</url-pattern>
</servlet-mapping>

The page that src's play_middle.jsp is in the /Web/IT_Techs subdirectory
below the context root.

Eventually, I expect I'll figure out how to make more efficient use of
Eclipse for this.
Re: New to JSP + [message #223991 is a reply to message #223969] Tue, 18 November 2008 20:59 Go to previous messageGo to next message
Chuck Moore is currently offline Chuck MooreFriend
Messages: 8
Registered: July 2009
Junior Member
Thanks.

Right now I'm stuck with 4.1 as the "production" server is using 4.0?

Once I get the have-to's done, I hope to learn how to have two flavors of
Tomcat on my box -- 4.1 and 6.x -- and then be able to work on qualifying
an application to work on 6.x.

Also, as noted in a different post, after the have-to's I'll figure out
how I can properly use Eclipse for a complete Tomcat based website
development platform. My workaround for now is rather ugly.

I will always be open for suggestions as I move along.
Re: New to JSP + [message #223999 is a reply to message #223969] Tue, 18 November 2008 21:08 Go to previous messageGo to next message
Chuck Moore is currently offline Chuck MooreFriend
Messages: 8
Registered: July 2009
Junior Member
Thanks.

Right now I'm stuck with 4.1 as the "production" box is using 4.0x

Once I get the have-to's done, I'm hoping I can learn/figure out how to
have 2 flavors of Tomcat running -- 4.1 and 6.x -- so that I can work on
qualifying than an app will work with/on 6.x

Also after the have-to's, I hope to be able to spend the time learning how
to use Eclipse properly for dynamic web development and J2EE work. All of
my previous Java work on Eclipse have been for stand alone purely Java
applications -- like a Sudoku solver I created in 2006 (it doesn't solve
all of them, but it does most of them).

As I keep moving along, I'll always be open for suggestions.
Re: New to JSP + [message #224007 is a reply to message #223985] Tue, 18 November 2008 21:47 Go to previous messageGo to next message
Chuck Moore is currently offline Chuck MooreFriend
Messages: 8
Registered: July 2009
Junior Member
Well, crud.

The "production" environment is Tomcat 4.0.3 using jre 1.4.2.
My dev environment is 4.1 and 1.5.0_07.
The resulting servlet major.minor level (49.0) is unsupported by the
"production" system. nuts.

guess I need to back up, if I can.
I don't find anything in text that set the version level.
Re: New to JSP + [message #224023 is a reply to message #224007] Tue, 18 November 2008 23:27 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2344
Registered: July 2009
Senior Member
Chuck Moore wrote:
> Well, crud.
>
> The "production" environment is Tomcat 4.0.3 using jre 1.4.2.
> My dev environment is 4.1 and 1.5.0_07.
> The resulting servlet major.minor level (49.0) is unsupported by the
> "production" system. nuts.
>
> guess I need to back up, if I can.
> I don't find anything in text that set the version level.

It's in the Java Compiler property page for your project; check the
Project menu in the menu bar.

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: New to JSP + [message #224031 is a reply to message #224023] Wed, 19 November 2008 13:03 Go to previous message
Chuck Moore is currently offline Chuck MooreFriend
Messages: 8
Registered: July 2009
Junior Member
! Thanks !

All I needed to do was set the compliance level to 1.4, rebuild, copy the
class file to WEB-INF/classes, restart Tomcat, and waza! .jsp displays,
without an actual .jsp file, and nothing in "work".

Thanks for the help.

Now I can concentrate on producing that actual .jsp I really need to have
work.
Previous Topic:Extending Axis 2 Webservice Wizards
Next Topic:Can not install WTP 3.0.2, version problem
Goto Forum:
  


Current Time: Sat Dec 27 01:01:36 GMT 2014

Powered by FUDForum. Page generated in 0.01853 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software