Enable JSP in Tomcat - java

I have setup Tomcat version 7.0.65 and I am trying to open a .jsp file. What I get as a result is something in the line of:
<%# include file="header.jsp" %>
<div id="body-0" class="body">
<div class="body-content">
<h1 class="title solid">What is Delivery IQ?</h1>
<div class="content">
<iframe width="853" height="480" src="https://www.youtube.com/embed/U6P8GxPCbyc" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
And not the actual site. Does anyone know what do I have to do in order to get it working?

You have to compile all the application and deploy to the Tomcat. Please read this link.
Also you could read enter link description here this could make it clear in first of the chapters.
Without RTFM you are just blindly clicking.

Related

CSS JS and Links not loading when deploy Spring boot as war in Tomcat

I have a Spring boot web application, it works fine when running as executable jar, but when I build as war and deploy to Tomcat, the css, js files are not loading and looking into further, I found out all links are pointing to root context path "/", I tried changing base href = "./" this fixed the problem of loading css and js, but I need to do that in lot of pages.
Also the links in <a> still points to root context path and to make this work I need prefix'./' . Below are my code snips,
CSS and JS link
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/signin.css" rel="stylesheet">
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
Tag
<a class="topHeader" href="/activateAccount"></a>
Is there a shortcut to fix this problem or should I change <base href> and <a href> in all the pages? Any help is highly appreciated.
There is no short cut or quick fix for this, I removed "/" in links in all anchor tags and that worked for me.
Example
<a href="/resetPassword" style="float: right;">
changed to
<a href="resetPassword" style="float: right;">

How to use jsp files of another project in eclipse

I am developing a web application using spring and hibernate in multiple modules.
And i want to use a module which is another project into different project.
But i am unable to use jsp files of that module.
Actually i have 2 projects named profile and SecondProject. And i have a jsp file named Insert.jsp in profile project. And Insert2.jsp file in SecondProject. Now i want to include Insert2.jsp file into Insert.jsp.
So how can i do this please suggest me.
here is the code of Insert.jsp file
<form action="/Profile/sendData" method="POST">
Name: <input type="text" name="name" />
<input type="submit" value="submit" />
</form>
<%#include file="Insert2.jsp" %>
You can use JSTL <c:import> Tag in Profile Project's Insert.jsp like this :
<c:import url="http://localhost:8080/SecondProject/insert2.jsp"/>
Note: Don't forgot to add jstl jar in classpath and also below line:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

HTML Java applet integration

I know this has been asked multiple times already, and I have already tried to use all of the solutions that I could find, but I wasn't able to get any success. I have a JApplet that works successfully (I've pasted the heirarchy below, as I don't think the code itself is relevant to the issue. I might be wrong). I also have some basic HTML code that seems to be correct based on the solutions that I have found. The problem is that I continue to get the same error:
(source: gyazo.com)
And I'm not sure why I'm getting it. Is it because everything in the heirarchy is a .java file?
my HTML file:
<html>
<head></head>
<body>
<applet width="950" height="600" archive="test.jar" code="OneQuestMapgen.OneQuestMapgen.class"></applet>
</body>
</html>
Hierarchy:
Files:
Any help would be appreciated. Thanks so much!
Can you try..
<applet width="950" height="600" archive="test.jar" code="OneQuestMapgen.OneQuestMapgen.class">
First, you need to close you <head> tag with </head> and do the same with the <body> tag.
Also, the <applet> tag has been deprecated in HTML4.01 and is not allowed in HTML5, so you should replace for <object> tag
So, if you are using it on Chrome, for instance. It will NOT work.
If your applet is in the same dir. as the html file you don't need to specify it as the browser searches for a location of the document in the same dir, if you have it elsewhere then it's ok to have the archive which should containt the path to the jar file.
Beside that you should consider adding to the code attribute also the package in which your class resideds, all separated by a dot code="OneQuestMapgen.OneQuestMapgen.class"
Shouldn't your html be like this?
<html>
<head></head> <!-- closing the head before the body -->
<body>
<applet width="950" height="600" code="OneQuestMapgen.OneQuestMapgen.class"
type="application/x-java-applet;jpi-version=6"
archive="test.jar">
</body>
</html>
in html5 it should be something like
<object type="application/x-java-applet" height="600" width="950">
<param name="code" value="OneQuestMapgen.OneQuestMapgen.class" />
<param name="archive" value="test.jar" />
Applet failed to run. No Java plug-in was found.
</object>

Java (IntelliJ Idea) - import class fail

I have a jsp page that imports a class from another module and package.
<%# page language="java" import="login.UserLogin" %>
<%# page contentType="text/html; charset=windows-1251" %>
<html>
<head>
<title>
Page title
</title>
</head>
<body>
<%-- Form to initiate POST --%>
<FORM name="test_form" method="post">
<INPUT type="submit" name="submit" value="Make Post"><BR>
</FORM>
</body>
</html>
I've corrected oll the dependances in IDE, but still get an error log:
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
The imported class is empty, so there are no further dependances.
Your JSP's are internally compiled to a servlets called [your_jsp]_jsp.java and your IDE is saying that it cannot find that compiled class.
Your problem is that your project is not compiled / not deployed in the server. Or maybe you have not well configured the output directory... I don't know, I don't use intelliJ...
Found! Error in Tomcat deployment config - it referenced to source folder instead of artifact

There are no changes reflected on deploying the theme in liferay 6.1.1

I am a newbie to liferay CMS. I am developing a theme in liferay 6.1.1. my problem is when i am making any changes to the theme it doesnt get reflected after deploying it.
Please check if i am in the right flow:
Firstly new --> liferay project --> selected theme
Deployed nthe theme which created the -diffs folder and the remaining all
folders in the docroot folder inside the theme.
Copied the portlet_normal.vm from the template folder from my theme and made
changes.
Pasted portlet_normal.vm in my theme inside the docroot(folder) --> _diffs(folder) --> templates(folder).
Redeployed the theme but there were no changes reflected.
My portlet_normal.vm file is:
<!DOCTYPE html>
#parse ($init)
<html class="#language("lang.dir")" dir="#language("lang.dir")" lang="$w3c_language_id">
<head>
<title>$the_title - $company_name</title>
$theme.include($top_head_include)
</head>
<body class="$css_class">
$theme.include($body_top_include)
#if ($is_signed_in)
#dockbar()
#end
<div id="wrapper">
#language("skip-to-content")
<header id="banner" role="banner">
<div id="heading">
<h1 class="site-title">
<a class="$logo_css_class" href="$site_default_url" title="#language("go-to") $site_name">
<img alt="$logo_description" height="$site_logo_height" src="$site_logo" width="$site_logo_width" />
</a>
#if ($show_site_name)
<span class="site-name" title="#language("go-to") $site_name">
$site_name
</span>
#end
</h1>
<h2 class="page-title">
<span>$the_title</span>
</h2>
</div>
#if (!$is_signed_in)
$sign_in_text
#end
#if ($has_navigation || $is_signed_in)
#parse ("$full_templates_path/navigation.vm")
#end
</header>
<div id="content">
**/*<nav class="site-breadcrumbs" id="breadcrumbs">
<h1>
<span>#language("breadcrumbs")</span>
</h1>
#breadcrumbs()
</nav>*/**
#if ($selectable)
$theme.include($content_include)
#else
$portletDisplay.recycle()
$portletDisplay.setTitle($the_title)
$theme.wrapPortlet("portlet.vm", $content_include)
#end
</div>
<footer id="footer" role="contentinfo">
<p class="powered-by">
#language("powered-by") Liferay
</p>
</footer>
</div>
$theme.include($body_bottom_include)
</body>
$theme.include($bottom_include)
</html>
Actually i want to hide the breadcrumbs getting displayed in the home page. so i have commented that particular portion in portlet_normal.vm
Any help regarding this will be appreciated , i am completely stuck in this.
You have two possibilities:
If you are developping, you can set the portal in dev mode adding
include-and-override=portal-developer.properties into your portal-ext.properties which should be under the portal root.
If you are in production this option should be disabled and you should check the following
Try to open the XML file build-common-theme.xml under the themes folder in your SDK and remove all the preservelastmodified="true" (or set them to false).
preservelastmodified, when true will not update the files timestamp in your theme project. Therefore, your application server will not detect the changes and redeploy the theme.
From step 1 it seems that you are using Eclipse to create Liferay theme project. Whenevr you create the project you will get
Now all you need to do is, change the files within the _diffs directory and build the theme with ant file build.xml, rest will be taken care by the build file. I am not sure why steps 3 and 4 required.
If the problem still exists, couple of points to look at are :
velocity.engine.resource.manager.cache.enabled=false
set this property in your portal-ext.properties and restart the server.

Categories