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

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>

Related

Use jsp:forward to forward to another page

I am learning about jsp and servlet. In an online tutorial, he used <jsp: forward> to move to another jsp page.
<jsp:forward page="home"></jsp:forward>
The directory tree: (eclipse)
The directory tree
I don't understand why when I run the program, the index.jsp file in the home directory is run. Why is he using <jsp: forward page = "home"> </ jsp: forward> instead of <jsp: forward page = "/ WEB-INF / views / home / index.jsp "> </ jsp: forward>
Can someone please explain me the using the relative url in web project.
Thank you so much !

How to use <c:url> in <c:import> on Java?

I'm trying to import a JSP using c:import and c:url, but it tells me it couldn't find the file. I tryed using a link to see if it opens the file, and it works fine. So, I suppose the path is correct, but it isnt't working.
My code is like this:
<c:url value="/cabecalho.jsp" var="cabecalho" />
<c:import value="${cabecalho}"></c:import> //page don't open
link //to test the path
If I use <c:url value="cabecalho.jsp" /> it works fine!
What must be happening?
c:url gives You absolute path from internet like http://www.somehost.com . c:import wants relative path to jsp on server.

What should i specify in action attribute of form tag in this case?

i want to send the form data to Controller.java servlet which is in the directory Source Package/mvc/Contoller.java of Netbeans
// mvc is the package name
i've tried action="/Controller"
action="mvc/Controller"
action="/mvc/Controller
but these are not working.
Just action="Controller" would be fine.
The mappings of the servlets is done in web.xml file which you can find in your project folder.

finding render path for file in eclipse workspace

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

Linking Files And Directory Structuring

I'm working on a web project using java/ jsp/ servlets/ html/ css in eclipse tomcat, where everything is in the WebContent folder.
In my jsp files... When I try to include other jsp files (using a link like "/fileName.jsp" in jsp include directive) I can do that successfully.
But When I try to include image files (using a link like "/fileName.jpg" in the <img src=""> tag) nothing happens.
Nothing happens because instead of looking in the WebContent folder for image file it looks in the tomcat home directory, i.e.
Instead of looking at "http ://localhost:port/projectName/..." it looks at "http: //localhost:port/..."
Why does it look at the wrong location only with <img src=""> tags but not in <%# /> tag.
A workaround for this is that I start giving absolute paths "/projectName/..." However doing this means I'm hardcoding project name everywhere. This is what I do not want.
Don't include binary content in an ascii output. Why not just use the img tag? If you need to do something to produce a jpeg, I would use a Servlet.
Because the jsp-Links in the website are getting processed and the image links not. Either change the image path or develop an filter that changes the images'links.
Yes Templar, that could have been a way to solve my problem.
However, I simply changed the Context Root of my project from "Project Name" to "/" in Eclipse. This solved my problem.

Categories

Resources