I need to access a page allCommonPageLink.jsp from another page named add_edit.jsp
I have done <%# include file="/plan/common/allCommonPageLink.jsp" %>
Error /WEB-INF/ViewPages/plan/add_edit.jsp (line: 8, column: 42) File "/plan/common/allCommonPageLink.jsp" not found
NEW QUESTION::
how can I access an image form images folder from tray.jsp and add_edit.jsp
you should use
<%# include file="../../common/allCommonPageLink.jsp" %>
Using ../ takes you back to the previous directory from where you are now.
If your page is web-inf/viewpages/plan/page.html that means that your working dir is plan. Invoking ../ takes you to view pages. Invoking another ../ takes you to web-inf. And from web-inf you have access to the file by accessing common/anotherpage.jsp
You can read https://www.owasp.org/index.php/Path_Traversal for more info
make it
<%# include file="WEB-INF/common/allCommonPageLink.jsp" %>
the file allCommonPageLink.jsp is not under the plan folder, fix he path and try again, hope this would fix your issue.
This will work
<%# include file="common/allCommonPageLink.jsp" %>
OR
You have to go back up to two folders plan and viewPages in order to access this folder in that file so this will work for you
<%# include file="../../common/allCommonPageLink.jsp" %>
You can use
<%# include file="../../common/allCommonPageLink.jsp" %>
When you add ../ it it will refer its parent folder or directory.
Related
I have seen a weird problem while using custom tag libraries.
In one of my jsp pages the relative uri path of the custom tld file is wrong.
Taglib is included in jsp page like below
<%# taglib prefix="aaa" uri="WEB-INF/bbb.tld" %>
Location of bbb.tld is : Stores\WebContent\WEB-INF\bbb.tld
This taglib is included in a parent jsp file, and not there jsp file is imported/included from parent.
My application has several other jsp files, where the same taglib is used with the correct path.
The same code is deployed in multiple test environments. In a few environments the code is throwing an error of "Failed to find resource", which is expected. But the taglib is working fine in most of the environments, instead of wrong path.
Why is there discrepancy in the behavior between different server environments? Does the server automatically look for all tld files if the uri can't be resolved?
I would recommend adding a trailing slash ('/') before WEB-INF. Could you try the following?
<%# taglib prefix="aaa" uri="/WEB-INF/bbb.tld" %>
Hopefully, this will give you consistent results across all you server instances. Also, having your TLD in Stores\WebContent\WEB-INF\bbb.tld seems to be related to be using an IDE (e.g. Eclipse) to develop your application. Once you export your application as an EAR or WAR the path will look more like Stores.war/WEB-INF/bbb.tld
(server Tomcat7v)
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
First Name:<c:out value="${param.fname}"></c:out><br/>
Last Name:<c:out value="${param.lname}"></c:out>
in the previous JSP and I am getting
Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
this error.
But when I try to find out the jars there were lots of version of that I am confused with which one should I use??
You need to put jstl jar in your classpath. See details at https://stackoverflow.com/tags/jstl/info
I were using Tomcat 7v which uses servlet 3.0 so I had to use jstl1.2.1 jars
i have the following pice of code:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
If i want to run the programm i get the following error message:
HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
My JAR Files are in the WEB-INF/lib/ folder
--->javax.servlet.jsp.jstl-1.2.1-javadoc.jar (IMP)
--->javax.servlet.jsp.jstl-api-1.2.1-javadoc.jar (API)
I use the WEB.xml Version 3.0
So please can someone help me?!
Thanks
It seems you have added the javadoc of the JSTL instead of the code. Try downloading this one and add it to your lib directory:
http://mvnrepository.com/artifact/javax.servlet/jstl/1.2
I have a .java file containing a public class. It is located under the 'web pages' folder (not under web-inf folder).
On my jsp page I have imported it as: <%# page import="packagename.javafilename;" %>
When I run jsp file, I get error as:
Unable to compile class for jsp.
Only a type can be imported. Packagename.filename resolves to a package
As mentioned in the comments there seems to be a missing % towards the end. Here is the way to import classes in jsp
// To import one class
<%# page import="com.xyz.MyClass" %>
OR
// To import multiple classes from the com.xyz package
<%# page import="com.xyz.*" %>
From your question things are not very clear.
First of all jsp cannot access .java but a .class file i.e. you have to keep your code compiled.
Secondly the class should be in the WEB-INF/classes folder or a jar in WEB-INF/lib folder.
Use this syntax:
<%# page import="package.filename" %>
In the last import, you might need to add a semicolon after the end of the package.filename.
So, if you have like 3 imports, then in the 3rd import line make sure to put a semicolon as:
<%# page import="package.filename;" %>
One more thing, make sure that the class files are in WEB-INF/classes folder.
I'm trying to add Google Maps onto my JSPs by using the Googlemaps taglib.
I've added this into my maven pom
<dependency>
<groupId>com.lamatek</groupId>
<artifactId>googlemaps</artifactId>
<version>0.98c</version>
<scope>provided<>/scope
</dependency>
This then included the googlemaps-0.98c library under my project libraries in NetBeans, I right clicked and selected Manually install artifact and located the googlemaps.jar file I had downloaded.
I've then added this into my taglibs file
<%#taglib prefix="googlemaps" uri="/WEB-INF/googlemaps" %>
And have then included this where I actually want to show a map on my jsp
<googlemaps:map id="map" width="250" height="300" version="2" type="STREET"
zoom="12">
<googlemaps:key domain="localhost" key="xxxx"/>
<googlemaps:point id="point1" address="74 Connors Lane" city="Elkton"
state="MD" zipcode="21921" country="US"/>
<googlemaps:marker id="marker1" point="point1"/>
</googlemaps:map>
But when I load up my application, I get the following error.
org.apache.jasper.JasperException: /jsp/dashboard.jsp(1,1) /jsp/common/taglibs.jsp(6,56) PWC6117: File "/WEB-INF/googlemaps" not found
root cause
org.apache.jasper.JasperException: /jsp/common/taglibs.jsp(6,56) PWC6117: File "/WEB-INF/googlemaps" not found
Have I missed something simple? I'm unable to spot what I've done wrong so far..
Generally when you do this:
<%#taglib prefix="googlemaps" uri="/WEB-INF/googlemaps" %>
You are basically trying to say "the folder /WEB-INF/googlemaps has a bunch of .tag files for use" - which you don't.
Just browsing the documentation confirms this - it says you should be using this (note the usage of the tld extension):
<%# taglib uri="/WEB-INF/googlemaps.tld" prefix="googlemaps" %>
Source: http://www.lamatek.com/GoogleMaps/documentation.jsp#installation
If you set scope to provided in your pom it is not included in the war file and the taglib will not be found. You should change the scope to compile or runtime.
The URI should not be /WEB-INF/googlemaps.tld. It should match the value in the <uri> tag in the googlemaps.tld.
Open up the googlemaps.jar, find the googlemaps.tld, and find the <uri> tag. That's the URI you need.
UPDATE:
I just downloaded the googlemaps.jar. I'm incorrect; the URI is indeed <uri>/WEB-INF/googlemaps.tld</uri>.
That suggests that you have to extract the googlemaps.tld file and put it under /WEB-INF in your web context, be it WAR or exploded.