Foren

How to render the content of a server location (Ex. Tomcat 7)

thumbnail
Laura Liparulo, geändert vor 11 Jahren.

How to render the content of a server location (Ex. Tomcat 7)

Junior Member Beiträge: 38 Beitrittsdatum: 30.06.12 Neueste Beiträge
This is a short but useful tutorial. I've googled for 3 hours before understanding how to access a tomcat folder location.
The following example should help you.

If you want to render images from a server location in Tomcat 7, you need to create a <em>your-web-app/META-INF/context.xml </em> file and specify a location:
<!--?xml version="1.0"?-->
<context path="/images" docBase="/home/laura/gallery" reloadable="true" />


Then in your .jsp file you will simply set the img tag like the following:
<img src="/images/picture.jpg" width="30%">


Alternatively you can also set the context xml file in the /tomcat-7.0.23/conf/Catalina/localhost folder, by giving it the same name of the webapp, (that is yourWebApp.xml).
I prefer to place the file in the meta-inf folder of the project so I can control il in the IDE enviroment.

Discussions are welcome :-)
thumbnail
Hitoshi Ozawa, geändert vor 11 Jahren.

RE: How to render the content of a server location (Ex. Tomcat 7)

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Normally, we want to have img folder inside the portlet so when the portlet is deployed, images will be deployed with it and when the portlet is undeployed, images will be deleted with it.
thumbnail
Laura Liparulo, geändert vor 11 Jahren.

RE: How to render the content of a server location (Ex. Tomcat 7)

Junior Member Beiträge: 38 Beitrittsdatum: 30.06.12 Neueste Beiträge
Of course I've written it for my localhost development application stage.
Well I've read about it. The application that I am developing (for my Master thesis :lolemoticon is a medical images viewer (dicom file extension....for which i'm using the powerful pixelmed java library).
In my project I need to access and render a database with images, that I'm putting in an external folder (somewhere on the server, probably directly in the tomcat folder.
So i need external access.

In the view-clinical-case.jsp i'm rendering the content like this (stub) snippet:
[code
]<%@include file="/init.jsp"%>
<portlet:defineObjects />

<%
CaseArchiveLocalServiceUtil.clearCache();
VolumeLocalServiceUtil.clearCache();
RoiLocalServiceUtil.clearCache();
ImageDBLocalServiceUtil.clearCache();
DicomLocalServiceUtil.clearCache();
ImageTypeLocalServiceUtil.clearCache();

CaseArchive caseArchive = (CaseArchive) request.getAttribute("case");
long caseId = caseArchive.getCaseId();
long volumeId = caseArchive.getVolumeId();
Volume volume = VolumeLocalServiceUtil.getVolume(volumeId);
List<ImageDB> images = ImageDBLocalServiceUtil.getAllImagesbyCaseId(caseId);
String notes = caseArchive.getNotes();
int i = 0;
%>
<portlet:renderURL var="cancelURL">
<portlet:param name="jspPage" value="/html/viewer/view.jsp" />
</portlet:renderURL>

<liferay-ui:error key="error-case" message="error-case-view" />

<br />
<h6>WEB DICOM VIEWER</h6>
<br />
VOLUME NAME:
<%=volume.getVolumeName()%>
<br />
VOLUME ID:
<%=volume.getVolumeId()%>
<br />
VOLUME OVERVIEW:
<%=volume.getOverview()%>
<br />
CASE NAME:
<%=caseArchive.getCaseName()%>
<br />
CASE ID:
<%=caseArchive.getCaseId()%>
<br />
<%
for (ImageDB image : images) {
i++;
%>

Image #<%=i%> : <img src="/images/volume.getVolumeName() + "/"+ caseArchive.getCaseName() + "/" + image.getImageName()" width="30%" /> <br />
<br />
<% } %>
<p>
<br /> <br /> <br /> <a href="<%=cancelURL.toString()%>">&larr;
Back to Menu</a>
</p>

when a 0.X or 1.0 version is ready I will release the code on sourceforge and put a portal online. Then I want to keep developing it... :-)
thumbnail
Laura Liparulo, geändert vor 11 Jahren.

RE: How to render the content of a server location (Ex. Tomcat 7)

Junior Member Beiträge: 38 Beitrittsdatum: 30.06.12 Neueste Beiträge
Consider that the image archive size might be big and I think that in the webapp directly it wouldn't be good for deployment. it might be 2GB folder...
Don't you think?
Let me know :-)