I have a JSP file that has a few imports at the top:
<%@ page import="org.json.JSONObject" %>
However, I have an issue because of a prior import resulting in a collision error with another import.
Is it possible to alias this import like you would in a traditional Java class?
import org.json.JSONObject jsOb
Note:
I know that there are no traditional aliasing mechanisms in Java. I just was not sure if there were some tag-based mechanism that would suffice. Additionally, using a fully qualified path to the package will not work, since the import is actually failing.
I am not aware of any aliasing mechanisms for packages in Java. The following is obviously illegal in Java:
import org.json.JSONObject;
import com.mypackage.JSONObject;
If there is a conflict in names in Java using 2 or more classes sharing the same name, you have to distinguish them using the full package name:
import org.json.JSONObject;
// code
JSONObject json = ...;
com.mypackage.JSONObject jsonObject = new com.mypackage.JSONObject(json);
The same analogy has to be used in the Java Servlet Pages. The best solution would be to avoid those classes with the same name if possible.