简体   繁体   中英

java class import to jsp and create object issue

Ok, so I completely scratched that direction. I'm just not familiar enough with servlet doget/doPost/remapping stuff. I have no one who knows about it so I'm flying blind.

I do, however, know how to do java programming. I just wanted to create a class so I could maintain an object oriented approach to the web site. I can easily create a class within a jsp with the standard

 public class foo{

 public foo
 {
  //constructor
 }

 public String getName()
 {
  return "some name";
 }

}

But, how do I do this in a .java/.class file and import it into a jsp for use? This is essentially the same question, different approach.

I have both the HelloWorld.java and HelloWorld.class in the web-inf/classes folder.

Make sure the HelloWorld.class is in WEB-INF/classes/com/HelloWorld/HelloWorld.class and the HelloWorld.java is in the package com.HelloWorld before it is compiled to the class file.

You need to map your Servlet. Don't use import for a Servlet. See https://stackoverflow.com/tags/servlets/info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM