Win a copy of liveProject: Build an ML Recommender System this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

JSP, Servlets Error: The import package cannot be resolved.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hai everyone. I have been working on a Web App project in eclipse Jsp Servlets. I have run into an error when trying to import a Java Class into a JSP file. [The import project(the package) cannot be resolved].

I have tried to clean the project but it's not working.

Kindly assist.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The proper answer to this is "don't put java code in your JSPs".

If you follow that then you won't hit this issue.
 
Saloon Keeper
Posts: 23553
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Charles!

While Dave's response might be a bit flip, it's true. You shouldn't put Java code (scriptlets) in JSPs. JSPs are not like ASPs or PHP, but rather they are expected to act primarily as View Templates in a Model/View/Controller architecture. The real logic should be in an associated servlet or a business bean invoked from a servlet.

Aside from the problems compiling code in JSPs. debugging code in JSPs is an absolute    Save yourself the pain.

So why do JSPs even allow scriptlets? Partly legacy - JSPs first came out when ASP was the popular web model for Windows webapps. Partly because there are a few special cases where they actually are the simplest and cleanest solution. But for general use, avoid all Java code in your JSPs. Life will be happier.
 
Saloon Keeper
Posts: 6932
164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to clarify:

Tim Holloway wrote:JSPs are not like ASPs or PHP


Here, ASP means Active Server Pages.

JSPs first came out when ASP was the popular web model for Windows webapps.


And here it means Application service provider. So easy to get confused, but Wikipedia's ASP disambiguation page to the rescue :-)
 
Tim Holloway
Saloon Keeper
Posts: 23553
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:
Here, ASP means Active Server Pages.

Acronym collision is a real problem. IBM used "CRA" to mean about 5 very different things in 5 different program products, for example. So as a general rule - and because many acronyms are meaningless to people not in discipline in question, I usually expand them.

Didn't think ASP would be a problem. But then, I don't know what Microsoft is using these days, so maybe the term is long out of date.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic