Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: How to Compile JSP in Eclipse (or other IDE)?

  1. #1
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Question How to Compile JSP in Eclipse (or other IDE)?

    Hey all,

    I recently started playing around with JSP and Tomcat- I have both working great, and I've been using a simple text editor to write the JSP files until now.

    That works fine, but I'm hoping to move onto a bigger project soon, so continuing to use the simple text editor will be a real exercise in tedium. I've tried opening the .jsp file in eclipse, but I'm unable to see compiler errors or the other eclipse magic such as autocomplete and automatic handling of imports, since I can't figure out how to set up a project for the webapp (I'm using eclipse EE indigo). I've tried googling for this, but everything I try leads me to the same deadend.

    I don't really need (or even want to) startup tomcat from eclipse (unless I have to in order to work with the .jsp files), all I really want to do is edit the JSP files in a more efficient way than using a basic text editor.

    So my question is, is there a good way to deal with editing of a jsp file or a webapp in general in eclipse, or any other IDE?

    Thanks for your time and any help you can provide, as I'm pretty much fumbling in the dark here.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How to Compile JSP in Eclipse (or other IDE)?

    I'm not sure there is a better way, so if you find one let me know. JSP files are basically Servlets, and from my understanding are compiled by the container (in your case Tomcat) at runtime. My workflow typically involves running the server, and having the .war 'hot' deployed to test through a browser (pain in the you know what). I know Eclipse has an compile error validator for JSP, its just never served me well enough to rely on it to any great extent.

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to Compile JSP in Eclipse (or other IDE)?

    That's what I was afraid of. I was hoping there was a simple solution that allowed for things like showing me what the compile-time errors were before actually running the server and looking at the page in a web browser. Oh well, guess I just have to go back to the old way of doing things without an IDE.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Member
    Join Date
    Oct 2011
    Posts
    42
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: How to Compile JSP in Eclipse (or other IDE)?

    Quote Originally Posted by KevinWorkman View Post

    So my question is, is there a good way to deal with editing of a jsp file or a webapp in general in eclipse, or any other IDE?
    You need to create a Java Dynamic Web project, then Eclipse will compile your JSP pages just like other java classes. You will see compile errors and autocomplete things.

    java exception
    Last edited by hns1984; January 11th, 2012 at 06:54 PM.

  5. The Following User Says Thank You to hns1984 For This Useful Post:

    KevinWorkman (October 31st, 2011)

  6. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to Compile JSP in Eclipse (or other IDE)?

    Quote Originally Posted by hns1984 View Post
    You need to create a Java Dynamic Web project, then Eclipse will compile your JSP pages just like other java classes. You will see compile errors and autocomplete things.
    Oh, sweet! This seems to be exactly what I'm looking for. I'll have to play around with it later. Thanks for the tip!
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How to Compile JSP in Eclipse (or other IDE)?

    For what its worth, web output cannot be viewed this way (that I know of) and I have found that the compile time error feature beyond buggy (perhaps the newer version of Eclipse is better?), the reason my post above says I do not rely on it to any great extent. Your mileage may very.

  8. The Following User Says Thank You to copeg For This Useful Post:

    KevinWorkman (October 31st, 2011)

  9. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to Compile JSP in Eclipse (or other IDE)?

    Quote Originally Posted by copeg View Post
    For what its worth, web output cannot be viewed this way (that I know of) and I have found that the compile time error feature beyond buggy (perhaps the newer version of Eclipse is better?), the reason my post above says I do not rely on it to any great extent. Your mileage may very.
    I'll definitely take that into consideration, but I'm okay with not viewing the web output this way- actually, I came across a ton of solutions trying to launch tomcat from eclipse, but I like to keep everything as separate as possible- I want writing, running, and viewing to be completely independent steps. Just a quirk of mine.

    But yeah, I'm already seeing compile-time error weirdness (wrong line numbers) without eclipse, so I'm going to tread cautiously as I add another layer. But this should help with the dumb stuff (basic syntax problems, classpath setup, etc), which is really what I was looking for.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. #8
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How to Compile JSP in Eclipse (or other IDE)?

    I came across a ton of solutions trying to launch tomcat from eclipse, but I like to keep everything as separate as possible- I want writing, running, and viewing to be completely independent steps. Just a quirk of mine.
    To give you some insight into my workflow that touches on the above (whether or not its best practice I cannot say but it works great for me)...I will typically have 2 servers: test and deployment. The test server I run locally through Eclipse, that facilitates doing all the error and output checking 'offline' - given SWT has browser capability, you might even be able to write a simple Eclipse plugin (or app) for viewing from localhost (if one doesn't already exist). When all is ready, I will deploy it onto the production server, often automating deployment using an ANT task (this is where ANT excels, as it can make the laborious process of compiling, copying, signing, transferring, etc...so simple). I'm probably getting way ahead of what you need now, but I'm just throwing out a few tips keep in mind. The above workflow has really stepped up my game over the past few years.

  11. #9
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to Compile JSP in Eclipse (or other IDE)?

    Quote Originally Posted by copeg View Post
    To give you some insight into my workflow that touches on the above (whether or not its best practice I cannot say but it works great for me)...I will typically have 2 servers: test and deployment. The test server I run locally through Eclipse, that facilitates doing all the error and output checking 'offline' - given SWT has browser capability, you might even be able to write a simple Eclipse plugin (or app) for viewing from localhost (if one doesn't already exist). When all is ready, I will deploy it onto the production server, often automating deployment using an ANT task (this is where ANT excels, as it can make the laborious process of compiling, copying, signing, transferring, etc...so simple). I'm probably getting way ahead of what you need now, but I'm just throwing out a few tips keep in mind. The above workflow has really stepped up my game over the past few years.
    That sounds like a pretty reliable setup. I'm definitely starting from scratch and working my way up- right now I'm only doing local stuff. When I get something worthwhile working (this week's project: registration and login!), I'll investigate hosting and deployment. Then I might try switching to something closer to your setup.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 24
    Last Post: August 4th, 2014, 12:49 PM
  2. Beginners Eclipse Tutorial. How to run first java application on Eclipse?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 13
    Last Post: June 24th, 2011, 12:26 AM
  3. Cannot get to compile
    By theoneyouenvy in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 19th, 2011, 10:17 PM
  4. Cannot get to compile
    By Goff256 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 19th, 2011, 01:09 PM