finding render path for file in eclipse workspace - java

I am trying to get a view.jsp file to display another .jsp file as a popup however I keep getting resource not found errors. Both files reside in the same directory in an Eclipse workspace. I was told that I need to use the files render path. I'm not sure how to find/create a render path for a file. The code activating the popup looks like this:
<a href="popupex.jsp" onclick="return popitup('RenderPathGoesHere.jsp')">
<input type="submit" value="Single Issue Upload" name="SingleIssueUpload"><br>
</a>
I'm kinda new to portlet development so any advice would be appreciated.
Thanks!

You can create portlet render url to redirect to jsp
i.e
<portlet:renderURL var="varName">
<portlet:param name="mvcPath" value="/html/foldername/RenderPathGoesHere.jsp" />
</portlet:renderURL>
And you can call like this
Click
HTH

Related

Render image in SpringMvc

I want my image show up in receipt_failure.html via such thymeleaf expression :
<img th:src="#{/src/main/resources/images/icons-alert-circle.png}" />
Image itself has settled in such SpringMVC folder structure:
I do not get where issue comes from because seems like I keep path structure but I am getting such error on my local environment
I moved /images folder into /static folder then fix html like this:
<img th:src="#{/images/icons-alert-circle.png}" />
and issue has been fixed

Add a source from another file in eclipse

Probably a ridiculously easy question here but I must be phrasing it weird in all of my search queries to find similar solutions.
So in my eclipse project I have a folder with some .jsp files in it. In another folder there are some .jpgs . I want to use one of these .jpg files in my .jsp but for some reason cannot get the classpath correct.
I tried right clicking and copying the qualified name and using that path but it wont link correctly for some reason...
my code looks like :
<img src="pikachu.jpg" height="300" />
I've also tried:
<img src="/My_Project_Name/WebContent/images/pikachu.jpg" height="300" />
Note: the Jsp is in:
/My_Project_Name/WebContent/JSP_FOLDER/JSP.jsp
thanks in advance - I know this should be a simple thing...
You need to use
<img src="<%= request.contextPath %>/images/pikachu.jpg" height="300" />
in your JSP.
<% request.contextPath %> will expand to the path under which your web server is serving your app.
Every resource inside of WebContent/ will then be accessible relative to this path.
Related:
http://kodejava.org/how-do-i-get-web-application-context-path-in-jsp/
Similar to Aaron's answer but I believe he has a typo in it (missing an equal sign).
Try this instead, which in my opinion is a little less messy:
<img src="${pageContext.request.contextPath}/images/pikachu.jpg" height="300" />
Aaron's solution would have been:
<img src="<%= request.getContextPath() %>/images/pikachu.jpg" height="300" />
If those don't work, view the page source and copy/paste us what the line looks like when you are using those.
Use
<img src="../images/pikachu.jpg" height="300" />
..(double dots) will move you to parent directory where you are having images folder.

Web Server AngularJs GET 404 not found

After moving my web project from Tomcat / directory to subfolder /WebApp I get an error GET http://localhost:8080/partials/view-worker-apps-used.html 404 (Not Found)
This is my project structure:
- WebApp
- partials
- view-worker-details.html
- view-worker-apps-used.html
- js
- controlers.js
- services.js
- index.html
First I load http://localhost:8080/WebApp/#/screen2
which is view-worker-details.html injected into index.html by $routeProvider
In loaded view-worker-details.html screen there is
<div ng-include="/partials/view-worker-apps-used.html"></div>
I prefer to not put WebApp prefix into path of ng-include.
How I can fix this problem?
You can take one of following approach.
Approach 1: If you are sure that your contextpath will not change then use following path in ng-include.
<div>
<div ng-include="/WebApp/#/screen2/partials/view-worker-apps-used.html"> </div>
</div>
Note: Remove single quote; it's not require so remove it to avoid confusion
Approach 2: If you think that your context name may change in future then I will suggest to re verify the location of following files.
a. First try by removing extra single quote
b. Verify the location of view-worker-apps-used.html file using following URL
/WebApp/#/screen2/partials/view-worker-apps-used.html
c. Verify the location of file in which you have added following line of code and make sure that relative path you have used as "partials/view-worker-apps-used.html" is valid.
<div>
<div ng-include="'partials/view-worker-apps-used.html'"> </div>
</div>
I hope it may help.

unable to locate exact location of image file in jsp page

i am saving my images through java coding in a folder called "files".
and in my jsp page i am trying to display that image using
<img alt="" src="${pageContext.request.contextPath}/files/IMG168.jpg"> But the image is not displaying! What could be the reason.
Please see the below images and suggest me solution for my problem.
You should put the files folder in WebContent directory.
Web pages contains as below
Web pages
|______page1.jsp
|______index.jsp
|______page2.jsp
|______WEB-INF
|______images
|______css
|
Just try this and see
<img alt="" src="../../files/IMG168.jpg">
Updated,
I think you have to get physical location of files folder and put it in to src. Example if your files folder in C:\visionbook\files your
src="C:\visionbook\files\IMG168.jpg"

how to call a jsp which is in a different WAR file

I have a click here link on a jsp. On clicking, another jsp which is in another WAR file has to be called. I'm using JSF frmework.
Can anyone help me out please....!!!
How about just anchor tag ?
Click Me
JSF
<h:outputLink value="http://someserver:port/app2/some.jsp"><h:outputText value="Click Me"/></h:outputLink>

Categories

Resources