Hey guys.
I am currently working on a project in JSP/Java Servlets, hope this is the right section. So, my problem regards mainly the form through which I will let the user input a file using <input type="file">. I did some research on the internet, telling me that I have two options (on the Servlet side) in order to get the file and store it in a directory on the server, namely O'Reilly's COS MultipartReques t and some other package issued by Apache. Now my problem is that, together with an image upload, I want the user to input other details in the form. I am managing to get the file on the server, however I still cannot get the other details (from textboxes, textareas and drop-down selections) since the form MUST have the enctype="multip art/form-data" property in order for the file upload to work.
Any ideas regarding what I am doing wrong? Or maybe how should I code this task?
Here is the source code: - <table align="center" cellspacing="1"><form action="AddTrip" enctype="multipart/form-data" method="POST">
-
<tbody>
-
<tr>
-
<td>Trip Name</td>
-
<td><input type="text" name="Name" value="" /></td>
-
</tr>
-
<tr>
-
<td>Description</td>
-
<td><textarea name="Description" rows="3" cols="20" value=""></textarea></td>
-
</tr>
-
<tr>
-
<td>Category</td>
-
<td><select name="Category" size="4">
-
<option>Cruise</option>
-
<option>Tour</option>
-
<option>Park</option>
-
<option>History</option>
-
<option>Eco-Tourism</option>
-
</select></td>
-
</tr>
-
<tr>
-
<td>Price</td>
-
<td><input type="text" name="Price" value="" /></td>
-
</tr>
-
<tr>
-
<td>Start Date</td>
-
<td><input name="StartDate" onfocus="showCalendarControl(this);" type="text"></td>
-
</tr>
-
<tr>
-
<td>End Date</td>
-
<td><input name="EndDate" onfocus="showCalendarControl(this);" type="text"></td>
-
</tr>
-
<tr>
-
<td>Country</td>
-
<td><select name="Country" size="4">
-
<option>Malta</option>
-
<option>Gozo</option>
-
<option>Comino</option>
-
<option>Sicily</option>
-
<option>Ibiza</option>
-
<option>Greece</option>
-
</select></td>
-
</tr>
-
<tr>
-
<td>Places Available</td>
-
<td><input name="Places" type="text" value=""/></td>
-
</tr>
-
<tr>
-
<td>Upload Picture</td>
-
<td><input type="file" name="uploaded" accept="image/gif, image/jpeg, image/png, image.jpg"/></td>
-
</tr>
-
<tr>
-
<td colspan="2" align="center"><input type="submit" id="search-submit-long" name="save" value="Submit Trip"></td>
-
</tr>
-
</tbody>
-
</form></table>
-
-
[Servlet]
-
-
String Name = request.getParameter("Name");
-
String Description = request.getParameter("Description");
-
String Category = request.getParameter("Category");
-
String Price = request.getParameter("Price");
-
String StartDate = request.getParameter("StartDate");
-
String EndDate = request.getParameter("EndDate");
-
String Country = request.getParameter("Country");
-
String Places = request.getParameter("Places");
-
-
MultipartRequest multipartRequest = new MultipartRequest(request, getServletContext().getRealPath("/images/"), /* 1MB */ 1024 * 1024, new DefaultFileRenamePolicy());
-
if (multipartRequest.getParameter("save") != null) {
-
upload(request, response, multipartRequest);
-
} else {
-
throw new IOException("Display Upload Dialogue");
-
}
-
-
-
} catch(Exception e) {
-
response.sendRedirect("Error.jsp?error=Entry of new trip failed. Please try again! Error is " + e.toString());
-
out.close();
-
}
2 8420
hello newcomer...
i think that you may get better results if you uploaded this thread into the Java section...
i for one have no idea how to do what you wanna do but i think someone may know inside the other section...
try to rename to your thread asking on the front, how to...
thanks mate...
cya
MusoFreak200
i have servlet code for inserting the image and retrieving the image in database(MS-Access)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bura Tino |
last post by:
Hi,
I developing a system using JSP. People familiar with this technology
know that ServerPages are easier to maintain than Servlets, but they
can only have ASCII output.
With that as the backdrop, here's what I want to accomplish. I want
clicking on a link to cause a script to be executed on the server but
-->I don't want the browser to jump to another page<--.
|
by: joe |
last post by:
Any articles relating with
Uploading images files to server and resize the image by asp.net 2.0
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: prakharv |
last post by:
Hi All,
Below is the code which I am using to upload a jpeg file to the server. But the problem I am facing is that it is not copying the entire contents of the image file to the webserver and it doesn't works on IE.
Please, help me out as I am new to this and would be highly thankful if anyone has running code for uploading image files to the server using CGI either Perl or C.
This code i took it from net only.
#!/usr/bin/perl -w
|
by: Carey Carlan |
last post by:
Can the bright minds here point me to the java tools best suited to
interfacing a C++ library with the widest range of web servers?
Fundamental question from a Java newbie. I'm about to start a web app with
the business logic contained in a C++ DLL (could be a COM object if
necessary). It must be compiled to protect the intellectual property
within. My research to date indicates that java is both portable and
powerful enough to manage...
| |
by: pdesai007 |
last post by:
hi all,
i am trying to upload a image on to server with asp and AJAX, but it is not worked. so please give me information that upload an image to the server with java script without refeshing my original page.
thank you,
|
by: madhoriya22 |
last post by:
Hi,
while deploying applicatin tomcat server is throwing these exceptions :--
SEVERE: Servlet.service() for servlet RequestHandler threw exception
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:415)
at java.lang.Integer.parseInt(Integer.java:497)
at com.spi.defecttracker.controller.RequestHandler.processRequest(RequestHandler.java:54)
at...
|
by: thulaseeram |
last post by:
I am using iframe to store uploaded images, it is uploading fine in IE but it is not happening in firefox means first time it is uploading image if i try to upload second image it is not calling even java script function and not uploading the image in firefox. I am using this code in the button onclick event "attach_frame.upload();" here attach_frame is the iframe name and id to which the uploaded image should add. please can any one help me to...
|
by: jatin299 |
last post by:
hi ..problem in uploading image..using servlet to upload image in mysql..use html form so user given the path of image..but giving error.here is the code..help me on this.
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LoadImage extends HttpServlet{
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |