Open JSP Page directly in brower using URL - java

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

Related

My Dynamic Web Project welcome-file doesn't get affected by changes

This is a pretty strage and hassle problem i have here.
I created a Dynamic Web Project in Eclipse and created an HTML file named "inicio.html".
I put this into my web.xml <welcome-file> and all seemed to work okay.
I could Run on server without any problem.
Until i dragged a folder into my webapp.
folder in my project
Now when i run on server my file doesnt change at all, and even when i change the welcome-file from web.xml it doesn't change.
It looks like there's another file somewhere like a copy from the original "inicio.html" that's executing on my server.
this is an example of what's happening
I tried to change my TomCat's web.xml file and it doesn't works.
It's unlikely that the new IMG folder is relevant. Deployment Descriptors aren't really hot swappable.
Make sure automatic building is enabled on the Project menu, and then try right-clicking on the server in the Servers View and choosing "Clean Tomcat Work Directory". Otherwise, you'll need to restart the server for changes to take effect.

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.

Editing Folder content in tomcat manually?

I have a WAR file called ROOT.war where I uploaded into Tomcat few days back. There I have few "public" HTML pages like index.html, about.html etc. These pages has no connection with the programatic part of the application, instead containing a link for login.jsp.
Now, I need to change the content of the index.html and about.html. What I was used to do is rebuild the entire WAR file and re-uplaod it, but now can't do it for small and iterative changes like this because the application is in use.
So, can I simply access the webapps -> ROOT folder in Tomcat and replace the index.html? Will it affect the process of the application?
It works but avoid such practices which lead to discrepancies.
Follow standard deployment process - rebuild the entire WAR file and re-upload it during deployment window.
You can, and It will work. You can even change the JSP code. The only issue you may have is that when you redeploy a new version of the war, changes made in the server will ve overriden by the new version, so you better change it in the original tool also.

GlassFish Quandary

I am trying to install GlassFish (on a Mac) as directed by a book on Core JSF. When I go to
http://localhost:8080
I see the page as displayed in the book, with no problems. However, when I copy the login.war file to the directory specified in the book and try to go to the login page
http://localhost:8080/login
I simply see a 404 Error.
I /think/ I have copied the file correctly. What does this indicate? By virtue of the fact that I am able to see the page
http://localhost:8080
correctly does this mean that GlassFish has been appropriately installed? What does the 404 Error likely mean? Thanks. Conor.
The 404 error is the HTTP page not found error. This means, the page you are trying to access does not exist. I believe your application is not deployed on the server.
To deploy your application, go to server admin page localhost:4848 click on application from the navigation menu. From there click on Deploy and browse to the file location. You can also specify the context root where your application should be deployed.
However, your application might be deployed on the server with a different context root.
If you have a glassfish descriptor, then you can check your context root from there. However, If you do not have a glassfish descriptor then you need to create one.
In this descriptor you need to define your context root name.
<context-root>/foobar</context-root>
this means the application will be deployed on localhost:8080/foobar
Similarly, if you defined your context root as following:
<context-root>/</context-root>
Then your application will be deployed on localhost:8080/

display resource in j2ee web app by using url

i have simple j2ee web app. i packed it to a war file. The structure of war file is :
/..
images
css
WEB-INF
web.xml
wsdl
abc.wsdl
.....
i deployed it into ServiceMix (it uses jetty for web container). the app worked just fine.
now, my question is:
How can i display abc.wsdl file by using URL like:
http://localhost:8080/simpleapp/wsdl/abc.wsdl
I know this is not a good practice, but i just want to know how to do this.
try the following in
click here to view wsdl file
in any of the generated jsp / index.html which is rooted at the base of the webapp

Categories