How to set starting page in Netbeans Java Web project template? - java

When I run a java web project it always opens in my browser the "index.html" page, so I want to choose another page when the project starts.
How can I do it?
Thanks in advance.

Configure the URL to be used when you run your project as follows:
Select your project in the Projects panel, right click and select Properties... from the context menu.
Select Run from the list of categories.
You should see that Context Path already is set to something. It is set to /WebApplication1 in the sample screen shot below. Leave that field alone.
Specify the Relative URL you want to be used when NetBeans runs your application. By default it will be empty. The value you provide will be appended to the context path to construct the URL. In the screen shot below the relative URL is set to /Servlet1, so this will be be appended to the context path of /WebApplication1 to build the URL http://localhost:8080/WebApplication1/Servlet1 to be used when the application is run.
When your web application is run, the URL to be used is logged to the run window. Note the text Browsing: http://localhost:8080/WebApplication1/Servlet1 near the bottom of the screen shot.

Related

Output TestNG screenshot to Jenkins

I'm looking for a solution to output a TestNG/Selenium screenshot in Jenkins. Ideally, when a Jenkins job runs I want to either have the images embedded into the Console Output or have a link display so the user can view the screenshot in a separate window.
Here's a function I'm using right now:
#AfterMethod
public void takeScreenShotOnFailure(ITestResult testResult) throws IOException {
if (testResult.getStatus() == ITestResult.FAILURE) {
System.out.println("Status: " + testResult.getStatus());
System.out.println("<img src=\"data:image/png;base64," +
((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64) + "\" ></img>");
}
}
The problem is that Jenkins displays the output as plain text. I tried copying the output into an html page and it looks fine. So it appears that the way Jenkins presents the information causes Firefox/Chrome to display the html code as plaintext. Any idea how to get around this? Or is there a better way to get TestNG's takescreenshot functionality to work with Jenkins?
You archive the screenshot using the "archive the artifacts" option in the "post build actions" of the jenkins project configuration page.To archive first u need to set the custom workspace for the project.The custom workspace should point to the root directory or the folder which is containing the folder of screenshots.Then after archiving all the screenshots will appear as links in the project page.Here "reports" will be folders containing the screenshots or any file.reports is under The "QTP" folder which is mentioned in the custom workspace.pls use slash instead of backslash in the archive the artifacts option.
Project page:
using custom workspace in jenkins
archiving the artifacts using post build actions
Jenkins console output can not show the images. But It shows the links as links - you can click on it from the console output to the corresponding site.
So, your takeScreenShotOnFailure can be modified to move the image to a common ftp folder from the slave machine & provide the link in the console output.
You should be able to see the image immediately.
It supports http/ftp links.
Perhaps you can use the html publisher plugin.
https://wiki.jenkins-ci.org/display/JENKINS/HTML+Publisher+Plugin
Generate a basic html file with text and images, and it will show up as a clickable link on your job page.
The image will be stored together with all other build data in Jenkins.

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 find the path of the uploaded files on Weebly?

I'm trying to make my own website using Weebly. I want to include a Java Applet I made and therefore I must use an HTML snippet on the website. In the snippet I have to include the path of my uploaded Applet in order for it to run. How can I get this path, because I do not know where the files end up after uploading them. I saw in one post that each user gets a very specific path with each upload but how did they find this out? Is there a way?
not sure if you still need an answer to this....the path for uploaded files into your weebly site (via the Design Tab, then "edit HTML/CSS" menu is "/files/theme/yourfilename.js"
Weebly by default gives it's subdomain sites the ability to control content so when you upload anything to weebly via Code Editor (Weebly main -> Design -> Edit Html/CSS -> Add New Files)
the default address is
yoursubdomain.weebly.com/files/theme/filename.extension
For example if my file name is social-grey and is png extension and my subdomain is geniusknight ( http://geniusknight.weebly.com ) then the link would be:
geniusknight.weebly.com/files/theme/social-grey.png
Similarly for Javascript extension with name test would be
http://geniusknight.weebly.com/files/theme/test.js
and make sure in the source use the complete url and not the short ones like test.js because that doesn't work in subdomain sites for weebly.
Go to Design > Edit HTML/CSS > Assets folder.
Go to the image or file you'd like to reference and grab the URL.
e.g. http://www.weebly.com/editor/uploads/3/4/0/9/34091/custom_themes/647127941726820885/files/homelogos/codehs.jpg
To use a relative path instead of an absolute path, remove everything before /uploads...
e.g. /uploads/3/4/0/9/34091/custom_themes/647127941726820885/files/homelogos/codehs.jpg
Hope that helps!
Go to Weebly then design and edit html.
Left click a pre existing .png image, then in that same window right click over the image that pops up and go to open image in new tab.
In the new tab you will see the address in the address bar. It will look something like this...
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/yilogo.rar?1407684265479
You can drop the ?1407684265479 bit to have a direct url for your file!!!!
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/yilogo.rar
Then replace that file name in this case yilogo.rar with the file you have just uploaded or wish to use from your existing collection. E.g.
weebly.com/uploads/6/9/2/1/12851110/custom_themes/138585217722419571/files/flags.exe

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

Relative Path Question Running a Tomcat Server

So I have a file structure like below
http://dl.dropbox.com/u/322696/FolderPath.JPG
When I start the Tomcat Server, I'm trying to figure out where it's root folder begins with if I were just to start the server in the server window and access a jsp page within the jsp folder. I need to navigate to images/banner/name.jpg (trying to make an image file). I've set the servers context to '/projectname' (the black rectangle next to [repository]). I've tried like:
File image = new File("../images/banner/name.jpg"); //If its root was the jsp I accessed
No dice. Is there a method I could run to determine what the relative path should be?
Are you asking how to get the on disk path from within tomcat? If so you use the ServletContext.
getServletContext().getRealPath("/")

Categories