I am working on a web based project in eclipse on a system with jre 1.8 and Tomcat 8.
My application works fine on my system.
Now I have to deploy my application on a linux server machine.. As I am a novice I am facing some difficulties.
My server machine has Tomcat 7 installed.
For deployment , i was copying the sources from wtpwebapps from my system to /var/lib/tomcat7/webapps on my server machine.
But now only html webpages are showing up and all the jsp files are giving the HTTP: 404 The requested resource is not available.
My Folder Structure is MyProject/WebContent/(DisplayResults.jsp & Homepage.html) & servlet is located at MyProject/src/Utility/Servlet.java
Homepage.html
<form method="get" action="/MyProject/Servlet">
<input type='text' name='q' value='Type your text'><br>
<br> <input type="submit" value="Search">
</form>
Servlet.java
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String query = request.getParameter("q");
System.out.println("query is " + query);
request.setAttribute("itemList", list);
request.setAttribute("q", query);
RequestDispatcher view = request
.getRequestDispatcher("/DisplayResults.jsp");
view.forward(request, response);
}
DisplayResults.jsp
<%#page import="Utility.*"%>
<html>
<body bgcolor="#fdf5e6">
<table>
<td><c:forEach var="d" items="${itemList}">
<b><a href='<c:out value="${d.itemLink}"/>'>${d.itemTitle}</a></b>
<br>
<small>${d.itemLink}</small>
<p>${d.itemDesc}</p>
</c:forEach></td>
</table>
</body>
</html>
On server machine, the html file opens up but for jsp file it gives resource not available error.
I have read across through several related posts, I could not find the exact scenario being answered.I guess the issue is related to the class files for the jsp not being found. As I am copying the wtpwebapps folder manually , i think something is getting missed.
Kindly please help.
Also I would like to know where can I check errors on the server machine.
Since you are using eclipse you can create War file and deploy the same to your server machine's tomcat/webapps folder. Restart your Tomcat server and let tomcat auto load your application.
yourProject(Right Click)->export->web->war
There select your project, Provide name of the war file to be generated.
Note: Your application context will be same as your War file name.
In this way you can avoid any mistakes happening due to direct file transfer.
Another thing I noticed is that you are using your action url as /MyProject/Servlet.
Try using this in your form action Servlet.
Your form tag will become
<form method="get" action="Servlet">
Related
So I'm making an app with nodejs, express, and angularjs. I was following a couple of tutorials and decided to integrate into my project.
I have a index.html and there there is a button to create a multi-step form using Angularjs and UI-route. Form link
Then I found a youtube playlist for MEAN Stack, server works fine. As everyone I routed /public also.
app.use(express.static(__dirname + '/public'));
The problem starts here,
Button in the index.html it supposly goes to /app/views/forms/main-form.html to create the ui-view.
<div class="btn">
<form action="/app/views/forms/main-form.html">
<input type="submit" value="Get Started" />
</form>
</div>
Before I integrated express into my project, the path was working fine. Somehow, I think something to do with Express, when I click I get the following 404 error.
Refused to apply style from 'http://localhost:8080/app/views/forms/assets/css/form.css'
because its MIME type ('text/html') is not a supported stylesheet MIME type, and
strict MIME checking is enabled.
My problem is not about being a MIME type. The original path to CSS is /assets/css/form.css, but somehow it takes the form-main.html path at the beginning which is /app/views/forms also.
It is the same with formController as well. The controller normally is in the path of /app/controllers/formCtrl.js but the error goes like /app/views/forms/app/controllers/formCtrl.js
I would like to know how it takes two directories and combines them and why?
Edit
After using the CDN of Angularjs instead of local lib, it can get the link directly. But combining two directories is still continue to happening.
We have a JSF application that is currently working and live that uses Primefaces 7.0. The application allows users to upload files using the Primefaces FileUpload component which we then handle and process.
The firewall team is forcing a firewall to sit in front of the upload process which will block upload requests from hitting the application if it deems the file to not be suitable and return a 503 error to the browser. I am struggling to work out how we can handle the 503 error within the JSF application as the request never hits the server and I can't find a suitable attribute we can add to the FileUpload component that would listen for the 503 (tried using onerror as shown in code below but unfortunately it doesn't get called when the 503 error occurs). Without handling this error, nothing is presented to the user to suggest anything happened. Ideally we would present a growl message to the user asking them to try a different file type.
Below is the code currently for the FileUpload component however I'm not sure if it's any use as I'm looking more for advice than a code fix.
Anyone have any idea on how to potentially handle the 503?
Thanks
<p:fileUpload widgetVar="upload" id="upload"
disabled="#{user.filesRemaining eq 0}" label="SELECT FILES"
fileUploadListener="#{controller.handleFileUpload}"
styleclass="smallCommandButton" mode="advanced"
dragDropSupport="true" auto="true"
allowTypes="/(\.|\/)(jpeg|jpe|jpg|png|pdf)$/i" sizeLimit="10485760"
invalidSizeMessage="Image files must be under 10MB in size"
invalidFileMessage="Only JPG, PNG or PDF files can be uploaded"
onerror="#{controller.handleUploadError()}"
onstart="PF('uiBlocker').show()"
oncomplete="PF('uiBlocker').hide()">
</p:fileUpload>
Found a solution, I needed to add the below code to my fileUpload component, 'arguments' carries the information for the error:
onerror="handleUploadError(arguments)"
and then create the corresponding javascript function to handle the error e.g.
function handleUploadError(arguments) {
if(arguments[0].status === 503) {
**create message for user here**
}
}
I would like my server to point to resource files (i.e. css, js, images that are under /resources/default/VERSION_NUMBER/) to AWS S3 instead of delivering the files to the client side by itself.
Here are the relevant libraries and their version number taken from the pom file:
<javax.servlet-api.version>3.0.1</javax.servlet-api.version>
<weld-servlet.version>2.2.9.Final</weld-servlet.version>
<javax.el-api.version>3.0.0</javax.el-api.version>
<el-impl.version>2.2</el-impl.version>
<tomcat-jdbc.version>7.0.47</tomcat-jdbc.version>
<javax.faces.version>2.2.10</javax.faces.version>
<omnifaces.version>2.3</omnifaces.version>
<primefaces.version>6.1</primefaces.version>
I took a look at this post and modified my web.xml file with the following lines:
<context-param>
<param-name>org.omnifaces.CDN_RESOURCE_HANDLER_URLS</param-name>
<param-value>
remote:*=https://[URL]
</param-value>
</context-param>
And updated the library tag in all my css, javascript and image files mentioned in my xhtml file accordingly.
example:
<h:outputStylesheet library="default" name="styles/header.css"/>
Is modified to
<h:outputStylesheet library="remote" name="styles/header.css"/>
Now I am noticing that while the css files are loaded properly from the remote server, the url tags such the following present in the css files (hosted on the remote server) are not being downloaded from the local or remote server
background-image: url("#{resource['remote:images/add-default.png']}") !important;
Note that everything under my resource folder is already hosted in my remote server. I imagine JSF is failing to properly create the url from #{resource['remote:images/add-default.png'}] because in firefox console I get the error "The resource at “” was blocked because content blocking is enabled." for these files.
Once I figure out how to fix this, I would also like to know how to make it so all the jsf resources required on the client side that I don't explicitly specify in my xhtml files can be also hosted in the remote server.
Thank you!
I have a web application and now we want to move that from windows to linux environment.Here issue is,If i use enctype="multipart/form-data" in form tag then post request fails.For testing purpose i have removed enctype="multipart/form-data" from form tag and run in linux environment.Now post request success,But as per my knowledge for uploading files we should use enctype="multipart/form-data" in form tag.How to solve this issue?Please help me,For all help thanks in advance.
<form action="#routes.HoForms.uploadHoFormsByHeadOffice()" enctype="multipart/form-data" method="POST" id="shiftSummaryForm">//post request fails in linux
<form action="#routes.HoForms.uploadHoFormsByHeadOffice()" method="POST" id="shiftSummaryForm">//post request success in linux
I find the solution for my problem above.What the problem is in my tomcat folder there is no folder created at the time of installation or may be i was deleted that folder unfortunately.Now i have temp folder in my tomcat folder and everything works fine.Thank you all for your valuable suggestions.
I have an application which allows the users to upload and download files. The upload code looks like this:
[View]
<input type="file" name="file" id="file" />
<p />
<input type="submit" value="Upload" style="font-size:1em" />
</form>
[Controller]
public ActionResult Index(string id, FormCollection formCollection, HttpPostedFileBase file, int? FileID)
string filePath = "c:\\sandbox\\" + id + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + extension;
file.SaveAs(filePath);
The upload works fine. However, when I try to download the file just uploaded to "The Sandbox", I receive a 404 error. Here is the download code:
[View]
#f.Name
[Controller]
return File(a.FilePath, a.ContentType, a.Name); //File path is c:\Sandbox\filename
The application works flawlessly on my dev box, but fails when ported to IIS 7.5 box. Any thoughts would be extremely appreciated.
Thank you.
Found the problem!
When testing on dev box, the controller/action is located directly off the root. However, when deploying to the IIS box, the web site is placed in a sub-folder (xxxxxxx_deploy). Since the link to the controller action does not include the IIS sub-folder, it works on local box.
Thank you Mike!