Cannot run/debug jsp page from within IntelliJ using Tomcat server - java

I created a new project and created artifact for it.
When I run Tomcat from command prompt and go to: http://localhost:8080/IntelProject1/index.jsp
I can see my page.
But when I try to run it from IntelliJ, it opens empty page:
http://localhost:8080
and if I try to go to:
http://localhost:8080/IntelProject1/index.jsp
this is what it displays:
HTTP Status 404 - /IntelProject1/index.jsp
type Status report
message /IntelProject1/index.jsp
description The requested resource is not available.
Apache Tomcat/7.0.57
The reason it is able to find it from tomcat is because I edited server.xml file in tomcat/conf folder:
<Context path="/IntelProject1" docBase="C:\Users\ibogojevic\Desktop\IntelProject1\web\JSP" />
But I want to be able to open it and debug from within IntelliJ
Maybe my artifact is wrong.
Any thoughts?

Open Debug Configuration in IntelliJ IDEA and make sure that Deploy applications configured in Tomcat checkbox is checked as it shown on the screenshot.

For me it worked with:
File >Project Structure >Artifacts
In the
Output Layout on the right side >"Available Elements?"
right click on the available libraries ( for me it was "Spring MVC-4.2.4.RELEASE")
Put into Lib
And it worked.

Related

Why Tomcat works fine when I put a .jsp but with a .html doesn't works?

I'm working with eclipse and I created a project, I put a test.html and test.jsp file in the root folder. In the URL of the Google Chrome I put this:
http://localhost:8080/project/test.html Error 404
http://localhost:8080/project/test.jsp Works (hello world!)
What is happening?
Double check if your test.html exists under this path:
"Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\project"
If exists, then it should be accessed normally, if not then you have to clean/build your application correctly or even try to restart eclipse.
Based on your follow-up comments about the custom Tomcat install and the project error message, it sounds like you either don't have Eclipse properly configured to use your Tomcat server, or you don't have your project associated with the Tomcat server you've set up, and so perhaps your changes arent being deployed properly. See if that issue has a quick fix suggestion (right click it) or go through your project settings and verify your selected server runtime. Sorry on phone can't give specific instructions.

Files not executing in any browser except IE

I am doing a simple dynamic web project in eclipse Luna with a set of JSP files and Tomcat web server. But problem is, whenever I run any of the JSP files, it gives an error "File name, directory name or volume label syntax is incorrect" on all browsers except IE. I have searched a lot for this but I only got answers for maven projects. Can someone please provide a simpler solution ? Thanks in advance
Solved : We just need to change the settings in Window > Preferences > General > Web Browser and click on new and add our own browser(FF or chrome) by giving its file path. Then it works.

Open JSP Page directly in brower using URL

I am using Apache-Tomcat-7 and I placed a jsp page( myjsp.jsp ) in
...\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\desktop\
I have started the tomcat and trying the following URL to open the jsp page
http://localhost:8089/desktop/myjsp.jsp
But it is giving 404. I donot want it to open through other means. Can any body tell me that what I am doing wrong?
P.S. localhost:8089 works fine for other applications and tomcate is configured to this port-8089.
EDIT
When I placed the myjsp.jsp in ROOT folder under
...\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ROOT\
and try
http://localhost:8089/myjsp.jsp
Now it works. So what is the reason that in the desktop folder the jsp was NOT found
OR
how can I access myjsp.jsp if it is placed within desktop folder?
Well one way is the way you have already done (by deploying it at the root context of the tomcat server). Although it would seem to work fine, I won't recommend doing that. Changing root context of tomcat to some other application/pages is for other purpose.
The best way to do is to create a small project (you need a dynamic web project with a proper deployment descriptor --> eclipse will do all this job by just a button click), then deploy this project to your tomcat server.
So lets say if you create your project as MyProjectOne, then just place your JSP page (lets call it test.jsp) under WebContent or src/main/webapp folder and you will be able to view your page as http://localhost:8089/MyProjectOne/test.jsp

How to open my resource in that localhost:8080/test/index.html?

Tomcat started in eclipse and also I'm able to open the following URL in the browser:
http://localhost:8080/test/index.html
But, I'm not able to open my resource in that page.
Error that I am getting is:
HTTP Status 404 - /
type Status report
message http:/test/index.html
description The requested resource (/test/index) is not available.
Apache Tomcat/6.0.29
Please, try the following steps in eclipse to deploy the project as a WAR File and not as an EAR File:
In the Project Explorer right click on test (which is the name of your project, if I got it right)
In the context menu choose Export->WAR file
In the dialog window that pops up click the Browse... button to choose the destination folder for the deployment. This should be the web application folder of your Tomcat installation: <TOMCAT_INSTALLATION>/webapps where <TOMCAT_INSTALLATION> is the folder you have installed Tomcat in.
Click Finish
Now start your Tomcat server. Assuming you have the index.html file in the WebContent folder of the test project in Eclipse, you should see the content of index.html in your browser when you open the URL.

Netbeans update, project no longer opens index page

Yesterday when I launched my java project, it opened a web browser and went to http://localhost:8080/ showing my application's login page. Today, after accepting the latest updates (bangs head against keyboard) it no longer loads my app and is loading the Glassfish index page...
GlassFish Server 3.1.2
Your server is now running
I've verified the context path of my app is correct and I'm really not sure what areas of netbeans other than project settings that I should take a look at.
from the comments above the problem is when you run project from netbeans
the url opens on
http://localhost:8080/
if thats the problem how i understands it then go to context.xml and make sure
there is path attribure like this
"just look at the path only"
<Context antiJARLocking="true" path="/account_2">
etc...
but as you said you already checked it "context path" but can you tell me which one
because there is context path in project properties in netbeans under RUN node
and there is also "specify relative url context path" option
netbeans-->projects---go to your project---> then right click then properties then go to run node under relative url put /account/login.html this should make it work

Categories