Upload a servlet page on a server - java

i create a web site with java, spring framework,apache tomcat 7 and NetBeans.The last days i try to upload on a server but i have problems. I talk with the admin of the server and he said me,the form of the uploaded server seems not to be correct.
I'm using svn(assembla) and i store there my project.Then from there i send it to the main server i want to run it.The project when it is in the assembla(and in the main server i want to run it) contains the following files:
nbproject
src (contains the conf,myproject(with all the .java files))
web (contains: META-INF,WEB-INF,index.jsp)
and the folowing xml files: build,catalog,My-build and these files:command-To-Deploy.txt,My-build.properties
Moreover.My start page is a login page.At the index page i have only this line of code:
<c:redirect url="/log"/>
log is the URI i want to redirect the page.He told me that there is no log.jsp(the jsp for the log i named it as mainLogin.jsp). I'm not sure but i think that this is not a problem.
Does anyone who uploads before servlet knows what should i do and what files should i upload?

If you just uploaded java files to a server, they won't do much good. You need to compile them, preferable packaged into a jar, for the jsp to call them. Also, unless you're using libraries/javascript to change it, the url path operates explicitly like a file path. www.mysite.com/folder/file.jsp will look in /folder/ for the file name file.jsp to serve. So the url 'log' has no way of magically knowing that you want it to access mainLogin.jsp.

Related

java applet ClassNotFoundException with codebase

I'm starting to work on an applet that will replace an existing one. Having never developed an applet before, I thought I'd get going with the popular HelloWorld example. I am able to run it a couple different ways: in the appletviewer, and also in a browser if I put the JAR file containing the HelloWorld class in the same directory as the HTML (i.e. http://localhost:8080/myApp). I also got it to work when I put the JAR in a directory called HelloWorld just below the myApp directory and specified the codebase parameter in the <applet> tag as HelloWorld. But when I try to specify WEB-INF directories such as classes or lib, I get a ClassNotFoundException. What am I doing wrong?
But when I try to specify WEB-INF directories such as classes or lib, I get a ClassNotFoundException. What am I doing wrong?
Those directories are only meant for classes/jars that are used in JSP and servlets (i.e. the stuff the server needs). The resources inside them are available to site visitors. In this sense 'visitor' means a User Agent (i.e. a browser) or a client side plug-in (such as Flash or the JRE).
You can confirm this for yourself by pasting the full URL to the Jar in the web browser address bar and hit 'enter' to browser to it. The server will give a message back to the effect 'forbidden'.
See also the WEB-INF info. page which expands:
WEB-INF is the name of a folder found in Java web applications. It is used to store deployment information such as the web.xml, required library files and compiled class files. It is normally not accessible from web. Any files which you want to put on war but do not want to make to public then web-inf is the place where you can keep those files.

Updated Jsp Is Not Being Translated Into Java File In iplanet Web Server

I am new to an iPlanet web server. There is a requirement for my project: I need to debug it by placing: <%System.out.println("this working fine Kind of messages"+a);%>.
I have updated some part of my JSP to debug whether the corresponding values are being populated from back-end application correct or not. When I placed JSP and run an application from the browser, I'm getting a blank page, which means it is not translated properly. I checked and restarted the server as well, but I'm still facing the same issue and the .java is generated fine, but without content in it. Please suggest any right direction.
I have resolved this issue, after lots of experimenting like.
tried deleting particular generated .java file, did not solve that issue. but
path of generated folder were /generated/org/apache/jsp/*.java and their corresponding *.class, came till /generated/ dir and took backup of existing org dir and deleted it. once again I tried hitting URL on a browser to get that particular JSP result,I glad to see that my sysout are printing over webserver's console.
overall My suggestion is just to delete that generated *.java and *.class files iPlanet will regenerate whenever you request it.

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

Trying to access xml file in tomcat via URL, getting 404 error

I have a webapp deployed in Tomee+ 1.6.0 (tomcat 7.0). The app runs fine and I can access all pages. Within one of my app's folders (myapp/intructions/) I have placed a xml file that I will access via a client application.
The application will access the file for its configuration, and will be called via a batch file with the following command:
"C:\Java\jre7\bin\java" -cp MyApp.jar com.me.MyApplicationStart "argument1" "argument2"
Within MyApplicationStart the constructor tries to access the configuration from the URL
http://webserver:8080/myapp/instruction/myconfig.xml
As I have no control over the above methodology, this cannot be changed.
I would expect the xml to be downloaded (or fetched) and my application to work fine, but instead I get a 404 error. If I change the extension of my config file to .properties, everything works fine, but someone else other than me in the team insists that we use xml for the config file, since it will allow more automation features.
What gets me is why can't I access this xml (or any other) file from tomcat. It seems that in previous versions of tomcat this was not a problem, or at least not with files outside the WEB-INF folder. Now it is and it seems to be exclusive to xml files, which suggests that there's a configuration in place that prevents access to this extension from anywhere in the webapp.
Would anybody know what this configuration is, or what is the mechanics behind this error?
Thanks in advance.
for security reason, WEB-INF folder is not accessible from client side.
put your xml file in other location.
and try again, It will work

Access a page of one war file from another war file?

NOTE: I cannot package them into an EAR. Some constraints here.
I have 2 war files.
help.war and helpConnect.war
Both are placed in the same domain of GlassFish server.
From the index page of help.war am accessing a page in helpConnect.war like this..
Help Internal
This isn't working because when I try to access on the server, the URL its trying to access is like this..
http://localhost:8080/help/helpConnect/HelpInternal/index.htm
However, since helpConnect is a totally different war file I need the URL like this
http://localhost:8080/helpConnect/HelpInternal/index.htm
Any idea how to get this around?
You're using a relative path. You need an absolute path:
Help Internal

Categories