I am hosting a Wordpress site and would like to use it to publish an open source project. I'd like one of the main menu items to link to the javadoc for the project. For those, unfamiliar with Java, javadoc is a programmatically generated directory hierarchy with many (too many to convert manually) HTML files. The root level contains the index.html file that you start with and all the references are relative to that directory. How can I hook in this structure to the WP site? Converting each page by hand to a WP page is not an acceptable solution because there are too many of them and they change regularly.
The following worked for me:
Within my WordPress folder I created a folder javadoc - right next to wp-admin and the like - and dumped all the created JavaDoc-html in there. Going to http://my-blog/javadoc nicely displays the docs.
I'm a novice in this area, so this might be inadvisable from a best practice or security point of view. I'm actually very interested in an opinion on that!
Related
I have some Java code that I want to display on my web site. The point of sharing this code is not for for the viewers to use, it is just for them to see. (Although I am not opposed to them using it.) It is about 10 packages, each with 10 classes. What is the best way to make it viewable and navigatable in HTML? I am fairly new at this.
I am not necessarily trying to make it pretty...I just want it to be functional. I am also trying to avoid copy and pasting 100 individual files. I want to paste the entire Java project into a folder, then allow the user to access that folder and view its contents from on the website. So something like a folder system, where when they navigate to a .java, it displays the contents of that .java below the folder tree.
How can I accomplish this? I am not really sure where to begin.
I'll try to be short with the description of my situation:
I'm making a restaurant recommendation web site. I want users to be able to add a new restaurant and upload 1 picture of the restaurant (restaurant's profile picture). That picture will later be displayed when users search for the restaurants. Each time a new restaurant is added I want to create new folder for that restaurant and place the uploaded picture there.
I can upload an image and place on my file system, but when I try to display it it doesn't show.
<img src="\C:\glassfish4\glassfish\domains\domain1\applications\__internal\WebAppName\profilePicture.jpg" />
This is where I was originally placing the images, but they wouldn't show.
If I understood correctly from here that is not a good practice to reference images in this manner because then the browser will be looking for that location in user's machine.
I tried to place the images in:
C:\glassfish4\glassfish\domains\domain1\eclipseApps\WebAppName
because I figured that this is where WebContent folder is (please, correct me if I am wrong), and that this location is accessible with:
<img src="http://localhost:8080/WebAppName/..."/>
but that worked only for a short time. As soon as I redeployed my app the folders in which the pictures were placed had gone away (and they were created).
So my question(s) are:
How and where to place these images, and what should my src attribute look like in an html document (should it be like C:\... or http://localhost/...)?
What are conventions, practices for this, and how is this generally done?
And does redeployment has anything to do with my pictures being gone?
I found this post, but it did not solve my problem.
Note: - I am using glassfish4, and Java Servlets, JSP, JSTL/EL, and generally Java.
Thanks in advance!
And does redeployment has anything to do with my pictures being gone?
It does. When you redeployed your application, GAS removed the application directory at ${GAS_INST_DIR}\domains\${YOUR_DOMAIN_NAME}\application{YOUR_APP_BUNDLE_NAME}. Once you decided to store you images there, they are gone after the redeployment.
How and where to place these images
The most straightforward way is to put your files somewhere outside application server folder could be a solution but I would say just half a solution. Let's assume you store your pictures in a local folder /var/application/data. Later you decided to cluster your application. Now you are again in trouble. Each instance has its own /var/application/data directory and as a rule you do not know what node will handle a request for storing an image.
What are conventions, practices for this, and how is this generally done?
I would say it is you who decides what way to go according to the needs of your application. I will list the ways that are the most obvious. All have their own strength and weaknesses.
You can put the images in a local folder. The strong side is simplicity. Once you decide to cluster, you would have to remake this approach. If you go this way the most general approach would be to create a servlet that loads your images and in this case your src= will point to the servlet. Did not find a good example right away, but I think this example will give you an idea how to do it. The only thing I would suggest using finally block or if you use jdk 1.7 the try-with-resources for closing stream. Another thing you will need to pass file name as a parameter to the servlet.
Store images in database. It could be RDBMS or noSql. Down side is that not all RDBMSs work efficiently with binary data. Again src could point to a servlet that loads images from the DB. Here you should design your DB accordingly so you can retrieve images effectively. I would not choose this approach, but this is just a personal opinion. Cannot say how efficient the noSql databases are for storing binary data. You should do it yourself
Consider Webdav. In this case your src attribute will be a link to a resource in webdav server. You can use it in clustered environment, relatively simple implementation.
and what should my src attribute
look like in an html document (should it be like C:... or
http://localhost/...)?
Depends on the approach you choose. See item 1-3.
Hope that helps.
I have written extensive JavaDoc documentation on my application, and added lots of useful info at overview.html and package.html files (including links on the former to illustrations in doc-files/). Maven's Javadoc plugin nicely uses the standard javadoc tool to generate the classic JavaDoc frameset, but now I need to generate a PDF with the whole documentation.
AurigaDoclet generates very pretty PDFs, and I was able to make DocFlex work also. However, both ignore my overview.html and package.html files (tried both inside and outside Maven - the PDF will be a once-only thing, since I'd rather have the HTMLs on the long run).
Does anyone know how to make AurigaDoclet recoginze my non-Java files? Or, alternatively, another to generate a decent-looking PDF from either the source code or the JavaDoc-generated HTML?
Nailed it. After trying all the possible tools to generate straight from the source, I returned to HTMLDOC. It is not JavaDoc-aware, but it is so well built that a few tweaks are enough to make it generate a pretty usable PDF.
Here goes a step-by-step description of how I did it:
Download the software on the releases page;
Generate your traditional HTML docs in your preferred way (Ant, Maven, command-line javadoc - your choice);
The GUI is nice, but adding all files manually can be cumbersome, so just create a .book file with Document Type set to "Web Page", add one of the HTML files from your generated javadoc's root folder (e.g., overview-summary.html, anyone will do, it's just for reference on step 5). On the Output tab select the PDF format and set a name for it, and add other options to your heart's content (logos, colors, lots of cool stuff here). Save this project (say, myjavadocpdf.book) and close the GUI
Generate a list of all HTML files in your javadoc. I did it with Cygwin's find command (my DOS/cmd shell days are long over), but you can do anything you want, as long as you get a file list. In my case a find . | grep html$ | sort -r > files.txt did the trick;
For Windows users, dir /s/b *.html > files.txt should do the same (but keep in mind you may have to replace \s with /s if they appear like so on the next step).
Open the .book file generated on step 3 in your favorite pure text editor (as a programmer you should have strong opinions on that, so will keep my opinions to myself - NOT ;-) ) and append the list generated on step 4 to this .book file (it keeps the list of files at the end, making life really easy). Don't forget to fix the relative paths, if needed with a global search/replace (that's why you needed at least one file added on step 3 - to see which file path pattern htmldoc expects);
Now you should sort the files in a convenient order. I put my overview first, then package descriptions and each class, then the full index, and everything else at the end. Remember that any file you delete will become an external (hence broken) link, so choose wisely;
Save your .book file and re-open it on HTMLDOC. Voila: all files added and sorted. Click on generate. That's it!
You may want to fiddle with images (hint: use HTML width/height, not style/css). In the end, the resulting file is surprisingly good: nice looking and fully navigable for internal and external links. Impressive when you consider that the tool is not Java(Doc) aware at all...
EDIT: software is now free from original author; updated links, thank you #mohammed
According to the Sun JavaDoc FAQ, there's a couple of options -- mostly free, with one or two commercial offerings as well. Check it out at http://java.sun.com/j2se/javadoc/faq/index.html#print.
AurigaDoclet fails to process package.html.
For a fix see my comment at https://sourceforge.net/projects/aurigadoclet/forums/forum/339169/topic/1572199/index/page/1
If this question was bumped anyways, I can use this to link my ltxdoclet project.
This creates from the source (by being a JavaDoc plugin) documentation in LaTeX format, which you then can pass through PdfLaTeX to produce a PDF.
Optionally it also can include pretty-printed source code.
so now i think i have learned all basics and terminology for java. but what i don´t know is how to code and display a web page with Netbeans in Java.
the most tutorials contains lots of talks about different technologies "Java uses Java Beans, JSP and servlets" and so on. Where can i find short practical tutorials that actually teach me where to code what and then compile and where to put all the files (war, jar, ear..) in Glassfish to be able to see the output from a Web browser. Simples things that makes one understand all these different "layers" which are just classes using classes. Feels like i never get to know how i can put up a web server with Java cause I can´t find this kind of tutorials.
Would be great if someone could send some links to such practical stuff.
Thanks.
This is the first such document I found: http://www.java-tips.org/java-tutorials/tutorials/introduction-to-java-servlets-with-netbeans.html
More:
http://netbeans.org/kb/docs/web/quickstart-webapps.html
http://blogs.oracle.com/jonasdias/entry/webservices_with_jsp_on_netbeans
http://www.fuzzylizard.com/archives/2005/09/18/628/
http://cit.wta.swin.edu.au/cit/subjects/CITP0014/tutorials/netbeans/tomcat/Running_Tomcat_from_Netbeans.html
http://supportweb.cs.bham.ac.uk/documentation/java/servlets/netbeans-webapps/
I even found a small ebook on this (PDF!) http://www.comp.dit.ie/bduggan/Courses/projects/Getting%20Started%20with%20Tomcat%20&%20NetBeans.pdf
How do I code and display a web page with NetBeans in Java?
Let's go! Fire up NetBeans. I'm using NetBeans 6.7.1 with the Java EE stuff installed, and I've got a GlassFish installed and tied up, so I don't have to care about that stuff. Your setup might differ in the details.
Do a File->New Project, and pick "Java Web" from the categories. Select "Web Application" and hit Next. Enter a project name and tweak the location, if liked. Hit Next. The next page should have a server selection drop-down; as hinted above, mine has "GlassFIsh v2.1" selected. That's fine - as long as NetBeans can interact with a Java application server of some sort, this crash course will run okay.
Make a note of the "context path" - this will be based on the project name, and basically forms the base of the URL at which your application will reside. Hit Next. Ignore the next page, for now, which talks about various frameworks, and hit Finish.
Churn, churn. You should eventually see your web project created. It's a very simple application which contains a single JSP file, and that will be open in the main editor. It's got a bunch of HTML in it, and some JSP syntax.
Take a look at the project structure. You've got a "web pages" folder which contains a WEB-INF directory, and an index.jsp file. That's the same file you're looking at. WEB-INF is a standard directory which contains the metadata used to deploy your application, and also the compiled classes that power it.
The only thing you should need to do now, in order to get to the original objective, is to hit the big ol' Run button, or right-click on the project and select "Run" from the menu. NetBeans will compile, and then fire up your application server and deploy the application to it. Finally, your web browser should pop open a new tab with the classic "Hello, world" page in it.
At this point, what do you actually have? You've got an empty web project with a single JSP file in it. You could customise it, but that's maybe not very exciting. What you're really looking at is a basic framework in which you can apply your learning of JSP and of servlets as you get to grips with them.
How to proceed with said knowledge transfer? I recommend a decent book or two. The one I used to get going was "Beginning JSP, JSF and Tomcat Web Development: From Novice to Professional" (Zambon, Guilio; Apress; ISBN 1-59059-904-7), which has a decent beginner's guide to how JSP and servlets work together, and a handy reference guide for the former.
As soon as possible, you're going to want to migrate away from raw servlets and JSP to tying them together in a slightly more flexible way using one of the frameworks I skipped over earlier. I'm not going to tell you which one to learn; there are several pretty decent ones. Try Spring MVC, or Struts. Once again, I'd suggest getting a decent book.
I would start by taking a look at servlets and JSP. I found this book helpful when I read it: Head First Servlets and JSP
Netbeans comes with many sample projects, create a few and browse the source code.
A already working sample is always a good starting-point for your coding.
If you're also interested in using Eclipse, which makes it very simple to create and deploy web applications here's a nice tutorial - WTP Tutorials
Hi to start code and setting up web server with java follow the following procedure.
First you need to install Apache-Tomcat or Jetty any web container or servlet container.
And you have set the classpath of servlet-api.jar file.
Next you will have to save your web-page code stuff in web-apps folder of tomcat.In web-apps folder there you have to create a web-inf folder in which web.xml file is stored.And after writing servlet and jsp programs the compiled class files are stored in classes folder of web-inf folder.JSP files are stored along with WEB-INF folder.
You have to keep all the jar files in LIB folder of classes folder.
The web container will take care of initalizing servlet, loading class using inti method.Using service method it will create two objects request and response.
The Java EE stack is quite a mouthful. I suggest you just look at writing a Web Application (WAR), and deploy it to Tomcat.
Unfortunately doing a full WAR-file deployment is rather tedious so you generally want some help from your IDE or the web container.
The easiest place to start is probably installing and starting Tomcat and then fiddle with the files in the file system. There is an example application.
Im using Liferay Portal v5.2.3 Community Edition. I have the following two questions which i hope someone would be kind enough to answer.
1.) I want to add some content to the About Us Page of my intranet portal. I added Web Content Display portlet, and maximized the screen after adding content. But accessing the portal, it always appears minimized.
Any way to solve this issue ?
2.) When i try to add a template after creating a structure, i have to select the script file to be used. I found some vm files for 7Cogs portal,but couldnt find any for the organization i created . Where are these vm or css files located and which one to use ?
Please Help.
Thank You.
For 1) There's no need to "maximize" anything if that's the only thing you have on a page. Just choose the single-column layout and place your Web Content in this single column that covers the whole screen.
For 2) you'll have to add the templates yourself. Every template belongs to a structure, so if you create your own structure, you also need to create templates that can display this structure.
You create templates in the same place you create structures: Go to the Control Panel. In the "Web Content" section you find tabs for structures and templates. When you create a template you need to specify a matching structure there. Once you've done that you can choose that template in your web content