Click here to Skip to main content
15,881,173 members
Everything / Servlet

Servlet

servlet

Great Reads

by Han Bo Sun
In this tutorial, I am going to show the readers how to create an MVC application using Spring Boot, packaging as a self host WAR file, and execute using embedded Jetty application server.
by markkang
In this article, I will introduce how to call RESTful API in servlet.

Latest Articles

by Han Bo Sun
In this tutorial, I am going to show the readers how to create an MVC application using Spring Boot, packaging as a self host WAR file, and execute using embedded Jetty application server.
by markkang
In this article, I will introduce how to call RESTful API in servlet.

All Articles

Sort by Score

Servlet 

30 Jun 2013 by Sergey Alexandrovich Kryukov
Nobody is supposed to "recover a password", otherwise it would defeat one of the most important properties of the passwords. Passwords should not be recoverable, ever. If a password is lost, a brand new one should be created. I would say, the major purpose of password recovery would be...
7 Jul 2013 by Shubhashish_Mandal
int userId = Integer.parseInt(userID[i]);
28 Jan 2016 by Richard MacCutchan
Then please use Google to search for it. This is not a code-on-demand forum.
13 Feb 2019 by Han Bo Sun
In this tutorial, I am going to show the readers how to create an MVC application using Spring Boot, packaging as a self host WAR file, and execute using embedded Jetty application server.
20 Mar 2013 by Shubhashish_Mandal
Two probable reasons :1. the class doesn't contain the method it expected2. Mis-matched versions of that class. You compiled with the version that has that method and then tried to execute with another version that did not.
6 Jun 2013 by Prasad Khandekar
Hello Shruthi,Change your jsp code as shown below.
5 Jul 2013 by Shubhashish_Mandal
There are so many way to handle this.Process 1=============1. Create a hidden filed in your jsp called as "ReqType" .2.Set value as per Login/Logout request.2. Read this value in servletString type request.getParameter("ReqType")if("LOGOUT".equals(type)){//do logout...
8 Jul 2013 by Prasad Khandekar
Hello Mali,Since you are doing a sendRedirect, the browser is typically going to receives 301 response as shown below. This response instructs the browser that the requested resource has been moved to a different location and the browser should make a new request to the URL specified in the...
8 Jul 2013 by Shubhashish_Mandal
Try EL(Expression Language) instead of jsp scriptlet. Simply put ${loginMsg} in your logout page. To learn more ...http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html[^]
14 Jul 2013 by Shubhashish_Mandal
1. In filter grab the requested uri HttpServletRequest.getRequestURI()2. Create a list of do-not-filter .3. compare the uri with the list.
26 Dec 2013 by Marc Gabrie
Just embed Google Doc Viewer through an iframe and specify the PDF file you want to display. This is the code you should add:
29 Jan 2014 by Shubhashish_Mandal
did you check this : Caused by: java.lang.IllegalArgumentException: The servlets named [UploadDownloadFileServlet] and [com.uoc.elearning.web.UploadDownloadFileServlet] are both mapped to the url-pattern [/UploadDownloadFileServlet] which is not permitted
2 May 2014 by TorstenH.
http://www.java-samples.com/sh...
13 Sep 2015 by Manas_Kumar
Please try like below:out.println("");
28 Jan 2016 by Richard MacCutchan
Using Google to do your own research is generally considered a good idea.
6 Oct 2017 by OriginalGriff
Then good luck to you: but we are not here to monitor your progress, or do your homework. Either this is: 1) Homework and you want us to do it - and we don't do that: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there...
24 Oct 2017 by Patrice T
Quote: please tell me how to proceed without using database. Bad idea, the reason why everyone use databases is because they are efficient. If you have 50 rooms, 1 year of booking can be 18000 records, and you will have to read every single record for every single request, even worse every time...
17 Feb 2018 by ThilinaMD
try this code int pageNo = 1; if (request.getParameter("pageNo") != null) { pageNo = Integer.parseInt(request.getParameter("pageNo")); } instead of int pageNo=Integer.parseInt(request.getParameter("pageNo")); Error is caused due to at first when your servlet load there is no value for...
27 Nov 2018 by Richard MacCutchan
Looking at the ByteArrayInputStream (Java Platform SE 7 )[^] documentation it would appear that this parameter is a staging buffer for reading the input stream. You need to provide a buffer of some number of bytes for the upload to use.
16 Nov 2012 by paulalvin
I am building a website application using mysql, jsp and servlet. Now I dont have any idea on building crystal reports. What can I use to make a crytal report? THis will be my scenario...On the jsp page I want to have a button that says "Download" then I will generate crytal report based on...
19 Nov 2012 by Mac12334
I have a servlet in java.My servlet URL is http: //192.168.10.113:8080/collective-intellegence/UserClickPersonClassifier?userid=1&query=asp.netThis URL is giving json data.I am using a jquery ajax call to get the data.function SecondResultLink(link, userId, userInput) {try{ ...
23 Nov 2012 by paulalvin
I need to export my data displayed in the jsp page that came from the database to pdf or excel then download it...I am new with this...
24 Nov 2012 by TorstenH.
Creating PDF with Java and iText[^] @ vogella.comYou need to create the PDF and then send it as the answer to the client.
12 Dec 2012 by ommys
I am developing Spring MVC application.i created xml file in controller which i want to display in browser,please let me know how to display that file through spring mvc.
17 Jan 2013 by phil.o
Hi,You should have a service in the service's console related to your apache/tomcat installation.You have to see what is the name of the service, and if you want to launch it from command line, the syntax is :net start tomcat(Here I assume the name of the service is 'tomcat', but...
18 Jan 2013 by akminder2013
I am creating my first servlet.The steps i have followed are1) Created HTML page and saved it under "hello" directory.2)Under "Hello" directory i have created a sub directory named WEB-INF 3)WEB-INF is containing a another folder called classes.4)Now i have written a source code in a...
13 Feb 2013 by chinta123
I am using eclipse juno 4.2,java 1.7 and tomcat 7.But in my system when i create servlet the web.xml file doesn't create automatically.but anothor system it's create automatically web.xml file.I am totally confused.Is there anything to configure.Please help me out??I also add web.xml file...
13 Feb 2013 by TorstenH.
You have to go on in the wizard, don't just push "finish" after first page is filled out.3. page of the wizard has the option "generate web.xml descriptor".once the option is deselected it does not come up again by itself. Eclipse is assuming that it is your preferred setting.
17 Feb 2013 by unscathed18
I was wondering what kind of stuff or what should I learn in order to get my applications working online to make java server and work with html,css,javascript and databases.I've heard that the deal is working with JSP or something like that.I don't know exactly how it works, how should I...
17 Feb 2013 by Richard MacCutchan
I would recommend some of these tutorials[^], which will give you a reasonable grasp of Java; if you know C++ then it will not take long. There are also plenty of links to the other Java technologies.
17 Feb 2013 by H.Brydon
This question is asked many times about C or C++, and the wealth of books on those languages almost makes it too hard to answer.With Java however, the one book I would recommend is "Thinking in Java" by Bruce Eckel. It covers the language very well for a person that understands the basics...
20 Mar 2013 by lalitk369
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.apache.http.message.LineParser.hasProtocolVersion(Lorg/apache/http/util/CharArrayBuffer;I)Z at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:84) at...
29 Mar 2013 by Prasad Khandekar
Hello,Try changing the @webservlet annotation as shown below if you want your servlet to request with an extra path@webservlet(urlPatterns = {"/simpleservlet/*"})OR as shown below to listen to exact path@webservlet(urlPatterns = {"/simpleservlet"})Also make sure the webapp's web.xml...
29 Mar 2013 by Member 3369145
i have changed but showing same error, and in the changed line it is saysingMultiple markers at this line - webservlet cannot be resolved to a type - The attribute urlPatterns is undefined for the annotation type
29 Mar 2013 by Member 3369145
stack trace:--------------------------------------------------------------------------------------------Mar 29, 2013 10:03:46 PM org.apache.catalina.core.AprLifecycleListener initINFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments...
30 Mar 2013 by Prasad Khandekar
Hello,First of all remove following lines. from doPost method of your servlet.PrintWriter writer = response.getWriter();writer.println("");writer.println("checking Servlet");writer.println("check check...
29 Mar 2013 by Member 3369145
the jsp code:
30 Mar 2013 by Member 3369145
this is my code to print data in html from servletwhen running it is not showing datapackage finalpackage;import java.io.File;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;import java.util.List;import...
2 Apr 2013 by Prasad Khandekar
Hello,First I think jsp:setProperty for RowObject is not required. Secondly you are populating a list of RowObject in Servlet and setting it in request with key as 'resultss'. So in JSP you should be iterating over resultss. The corret JSP code would be
19 May 2013 by Shruthi GM
17 May 2013 by Richard MacCutchan
Start with http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/[^].
19 May 2013 by Shruthi GM
Code for generating new password:Jsp...
19 May 2013 by Samresh.ss
The above tag would give you a mail to link. I guess thats not you want. To send a mail with your generated password to an intended user, you might wantto use Java mail api.Please refer here and see if its helpful.
19 May 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
In JSP, a variable named session is implicitly available on each an every JSP page, which is the user's session. In other words, there is no need to retrieve the session, as it is already available to you.So, the below line is not necessary.HttpSession session...
30 May 2013 by Richard MacCutchan
Try the obvious place[^].
31 May 2013 by TorstenH.
You should try Java Monkeyhttp://jmonkeyengine.org/[^]
5 Jun 2013 by Member 3369145
i want to pass a list from the jsp page to a servlets, i need details.i want to pass the fruits[i] list in my code to servlets.following is my jsp code:====================================
6 Jun 2013 by Shruthi GM
Delete.jspUser is a pojo class.ModifyUser.java(Servlet class)protected void doPost(HttpServletRequest...
12 Jun 2013 by Shruthi GM
I have supposed to do 4 actions: CreateUser, Modify, View and delete. After deleting the user details, once again if click on ModifyUser or ViewUser im getting NullPointer Exception. Can some one please help me by correcting my code.index.jspNew...
14 Jun 2013 by Shruthi GM
Can some one please help why am i getting below error? "org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:438)"Whats wrong in my code??Contol is not getting moved from servlet to jsp. Please correct my code.Servlet Classprotected void...
5 Jul 2013 by bindu frm vzg
imagedownloadservlet.javap...
7 Jul 2013 by kellycx
How do I actually go about deleting multiple users using checkboxes? I have a page whereby it shows all created users with a checkbox beside each row created base on the number of created users. For now, I am only able to delete one checkbox at a time.I understand that for multiple deletion,...
8 Jul 2013 by shanmuga1509
In the loginpage get the username and password like request.getParameter("fieldname");and set the values in session parameters like session.setAttribute("fieldname");Get the values in logout servlet and remove by session.invalidate method.Use Sriptlets like this in login2.jsp]]>]]>
8 Jul 2013 by shanmuga1509
Use if else statements in jsp to avoid displaying null values]]>
8 Jul 2013 by mali_angel
In my Login.jsp page has line..It is for display a message.But before it displays ,it displays 'null'.How can i display message without display 'null' before that?here my code in servlet which call a message to jsp.private void...
9 Jul 2013 by shanmuga1509
login.jsp
14 Jul 2013 by divya.sweety
Can anyone tell me how to write a filter except for one url (page)? my filter is working but it applies to index page also. need to avoid index page from the filter. Im using jsp, servlet and java for a web app.
13 Aug 2013 by Member 10206813
Hi,,I have a Javascript Function. It contains some values right now i have hard coded it. But i need these values to be fetched from Db. So how will i call a Servelet from the Javascript. Also how the ArrayList from Servlet can be populated to Javascript?Thanks in Advance!!
19 Aug 2013 by alybin
I create session on JSP and set attribute "userName", but I can get this attribute only on first page. When I go to the next page, attribute "userName" is lost. How can I solve this problem ?HttpSession session = request.getSession(true);LoginManager loginManager = new...
22 Aug 2013 by thatraja
You forgot to include the next page code.Anyway here a simple tutorial. JSP Sessions[^]setAttribute/getAttribute properties used save/access session values.
28 Aug 2013 by mali_angel
Hey friends,I'm trying to do a online library system using jsp, servlet, java and mysql. In my system im tring to enter a book id through a text box and search the book then display the name of the box in next text box.my problem is how to display a db column value in a text box. values are...
29 Aug 2013 by grahamrenney
I've created a simplied version of your project and zipped the eclipse project to this URL: http://www.filedropper.com/librarysearch[^]. Use this as a base and add your search etc. There are many problems in your code e.g. the onclick handler cannot have tags. I would suggest you use struts or...
1 Sep 2013 by divya.sweety
Dear friendsI need to do a online bookshop using Java, JSP, Servlet, MySQL, DAO. in this delete functon i want to do :1. enter the book id in a textbox (txtbox 1)2. then pressing search button 3.then it search whether that book is in the db or not.4.if yes then book name should...
1 Sep 2013 by Shubhashish_Mandal
I have found b.getB_title()But where is b.setB_title(bookTitle)Note : Please follow java convention to write code.Class name should be start with Capital .Book b
4 Sep 2013 by Shubhashish_Mandal
function fire(action){document.formname.action = action;document.formName.submit();}
8 Sep 2013 by mali_angel
hey guys, im developing an online library. in here i want to borrow a book. before borrow need to get total amount of pending loans and fines. when i execute this function it says java.sql.SQLException: Column 'l_amt' not found table name is correct. can anyone one tell me whats wrong with...
10 Sep 2013 by mali_angel
hey guyz, Can anyone tell me how to get database data to a search textbox? im using html, jsp, servlet, java with DAO concepts. in here when I enter a letter (ex: ma) then it should show the list which are starting with "ma". Then user selects one of them. After user will see relavent...
11 Sep 2013 by Salman622
apply auto complete extender from ajax tool kit in your aspx page as below
10 Sep 2013 by Anurag Sinha V
Have a look at below links:http://www.java4s.com/jquery-tutorials/example-get-autocomplete-feature-in-javajsp-with-jquery-api/[^]http://viralpatel.net/blogs/tutorial-create-autocomplete-feature-with-java-jsp-jquery/[^]-anurag
10 Sep 2013 by bhaskar char T.N
jQuery UI Autocomplete - Default functionality
12 Sep 2013 by Nagy Vilmos
Firstly do not build the SQL as a string, that is just asking for trouble.Try something like this:import java.sql.DriverManager;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.SQLException;public class UpdateInventory{ // set this to some...
7 Oct 2013 by MidhunSibi
I need a sample web application program with some page flow with database login Pages: Login page -page1-page2 -page3 -page4Technology used: Jsp,servlets,sqlserver2008Please help me very urgent
7 Oct 2013 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.Try it yourself, you may find it...
29 Oct 2013 by Member 10268176
Dear Friends, i have a mysql database in which i have question and option table like that for one question has 4 options. now i want to display one question and there four options in my webpage and for next questions i want to use next button. In my servlet in doGet method i have...
31 Oct 2013 by thatraja
Crystal Reports XI for J2EE Startup Guide[^]
31 Oct 2013 by Member 10372712
does any one have code for receiving notification using html or servlets ,rather than broadcast receiver for android
8 Nov 2013 by Raghavendra M
I am developing a project with only jsp page , in jsp pages only , in scriptlets I am writing all servlet code. My doubt is , will dis kind of projects fallow MVC model and if fallow is Der any advantage over writing servlet separatly in src packages.?
9 Nov 2013 by Christian Graus
Please don't say 'dis' and 'der', it's retarded. Typos are fine, but 'street talk' is just annoying.Model/View/Controller is all the rage because the Microsoft framework uses it, but it's an old design pattern. MVC ( the microsoft version ) is the best web platform I've ever seen, but if...
22 Nov 2013 by JuliaSiv
Hi! Can somebody help me?I have a JSP page, where there are some questions. I want to save the answers to mysql database. All database connections are OK. But answers are not saved in database..Can, pliz, see my code, where are errors :(
4 Dec 2013 by Bipin Balachandran
index.html Name: Password: FirstServlet.javaimport java.io.IOException; import...
4 Dec 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
You should have Roles (like Admin or User) defined in the Table for each user.When, user logins into the system, you will also fetch Role of that user.If the Role is "admin", then redirect to adminhome.java, else if Role is "user", then redirect to user.java.
22 Dec 2013 by J Arun Prasath
Hello Friends, here my question :jQuery(function() { $("#itemname").autocomplete("AutoComp?mode=itemName");});Auto complete working fine.But, I am using this value to another ajax function.If I use this$(document).ready(function(){ ...
22 Dec 2013 by Er. Tushar Srivastava
Alright Friend,I may not possibly be able to give you any code at the moment 'cause I have to do few tests to do so but I can give you idea. See this is obvious, your code actually picks the value of the textbox which the user has entered. So, you have to do something like this.1....
24 Dec 2013 by jagadeesh kumar adabala
Hi, i'm Writing code like this, in Test.JSP $(document).ready(function() { $('#country').change(function(event) { var $country=$("select#country").val(); $.get('ActionServlet',{countryname:$country},function(responseJson)...
26 Dec 2013 by prabu19
Hi friends, I want to know my servlet and jsp version. i am using eclipse to buils java or android projects. pls help me to know that....
30 Jan 2014 by Malshani Wijekoon
Hey, I am doing a file upload and download system for an institute. Uploading part is working. Now i want to do download part using java code in windows. I found a method to download specific file in the directory. But i need to download several files from a directory placed in a server....
9 Feb 2014 by agha_ali22
I want to know is there a way that i can compress an image which is stored in oracle db as blob as i am converting blob to base64 image and then returning it in servlet.JSONObject obj = new JSONObject();if(!rs.next()){ return;} obj.put("NAME",...
9 Feb 2014 by Richard MacCutchan
Try https://www.google.com/search?q=compress+image+java[^].
20 Feb 2014 by jar8695
Hi all,I have a Java servlet (Java 1.6.0.29) running in Tomcat 7.0 all in Windows. SSL has been set up to encrypt information between the servlet and databases. Also, I have a test instance of the servlet and a Live instance. I am using SoapUI to simulate web requests and Wireshark to check...
21 Feb 2014 by jar8695
Hi all,I found an answer to this. I was assisted through another question on this forum;Servlet Security with SSL[^]Discovered that in my Eclipse development environment there were two context.xml files that were probably causing conflicting configurations.Also,iscovered that...
13 Mar 2014 by srkrishnan0509
hi friends i am new to java technology... i have little bit doubt in session..I have jsp's one is login.jsp and home.jsp, if login successfull control will move to home.jsp..if when i logout session will expire and control will redirect to index.jsp.. Now my doubt is if i logout and...
13 Mar 2014 by thatraja
Check thisSolving the logout problem properly and elegantly - Solutions for JSP pages and Struts[^]
27 Mar 2014 by prakash firefox
i send value in servlet by:List arr=new ArrayList(); arr.add("success"); String json=new Gson().toJson(arr); response.setContentType("application/json"); ...
3 Apr 2014 by Member 10717931
hi i constantly get error in import library which says it does not existimport org.apache.http.HttpResponse;import org.apache.http.HttpVersion;import org.apache.http.client.HttpClient;import org.apache.http.client.methods.HttpPost;import org.apache.http.entity.FileEntity;import...
10 Apr 2014 by Hareesh Malli
I have Jsp file in WEBCONTENT folder. My Jsp file name is FileUpload.jsp and code is Enter Document Id : ...
13 Apr 2014 by Darren_vms
Have you put your src folder in the WEB-INF directory ?If you have then this is the problem. You should have src in WEB-INF/classes./Darren
15 Apr 2014 by ankit1702
I have a web service client on java this client needs some values, I want to pass those values from the servlet and that servlet should be called from an Asp.net fileIs there any to do this?
30 Apr 2014 by Raghavendra M
I am writing code for userId availability check, now I am facing problem in submitting form, my javascript code is,function checkTeacherId(){alert(" in checkTecherId()");var status=document.getElementById("status");if(status=="Id in use choose another") return false;}html...
30 Apr 2014 by altaf008bd
Here span and font (coming from servlet) has the same id. So, you need to change font tag ids. Then you can use following modified version of your checkTeacherId() function:function checkTeacherId() { var status = $("#status").text(); if (status == "Id in use choose...