Click here to Skip to main content
15,889,874 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 Updated

Servlet 

19 Sep 2023 by Member 4246451
I have recently been working with the APG's cash drawer setup. I need with our existing cloud ERP (servlet-based) which uses JSP files to feed the pages in the web browser. I have recently bought a cash drawer 554A USB Pro cash drawers for APG...
2 Mar 2022 by Dev Learning
I would like to develop an web application with Spring Mvc, hibernate and Mysql. I know there are many Component libraries that facilitate the development of web applications like Primeng for Angular, Telerik and Infragistics for Asp.Net MVC. ...
20 Jan 2022 by Keshav 2022
The build is successful but I am unable to run the servlet as whenever I try to run I get 500-Internal Server error. Error snapshot attached for reference. It's giving some runtime exception. NetBeans IDE - 12.2 Apache Server -...
20 Jan 2022 by thatraja
After quick search, found out that nb-javac plugin[^] solves the issue. Below threads confirms the same servlets - @WebServlet fails in Netbeans 11.0 with java.lang.RuntimeException: com.example.NewServlet.(NewServlet.java:1) - Stack...
28 Dec 2021 by four systems
That code works import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; ...
27 Dec 2021 by four systems
The web page that sends parameters to servlet does not return result instead 404 appears it has been deployed and web xml has the details The web page is Wow ...
22 Oct 2021 by HIMANSHU SRIVASTAVA Oct2021
**This is loginpage.jsp file in which i am assigning servlet and method.** ...
14 Oct 2021 by HIMANSHU SRIVASTAVA Oct2021
```This register servlet class from where the exception is generating``` *Earlier the code was running fine on inputting fields in the page.But,after sometime it is generating this exception* package com.techblog.servlets; ...
15 Aug 2021 by User 15041314
i am getting this error.This error occurs when I send the confirmation code to the email of the registered user, but either succeeds or fails. javax.mail.MessagingException: Exception reading response; nested exception is: ...
25 Jun 2021 by User 15041314
Hi there, I am learning Servlet framework in Java and I created web project called this link GitHub - anar1996/EmployeeWebProject: I created web project called Employee with web project in Java.[^] So When I work myself own lesson, some idea goes...
25 Jun 2021 by samsmith07
Yes, We can create a website using static HTML pages and style them using CSS.
3 May 2021 by Suchita@101
I have a table below and Need to store location of data eg ABC location A1, EFD location A2,UVW at C1 dynamically in database. 1 2 3 4 A ABC EFD GHI JKH B PQR EFR QAE IOJ ...
5 Apr 2021 by laken1234
Hey guys! I am learning Java Servlets and trying to exercise with a project of my own. I am using two MySQL tables Users & Users Phones. As you can see from the attached files, each user can have multiple phone numbers. However I fail to make a...
4 Apr 2021 by Member 15127345
I have a client-server web app using Java and JavaScript. I would like to call a path "delete" from a method deleteBook using queryParam. I've searched the Internet, but I'm not sure how to do this. The called method was supposed to delete a book...
28 May 2020 by Member 14846960
i want to upload and display blob img and text data from data base in jsp using in netbens 8 but showing some error in code .the code is below
28 May 2020 by Member 11432405
I want to display multiple blob images from database on basis of email id but i can only get one image and other image are associated with same email id is not displaying not displaying i need your help to display multiple images from database . What I have tried: package...
14 Apr 2020 by MadMyche
String sql = "update boq set hsn_Code='"+HSN_CODE+"', is_hsnConfirmed='"+HSNCODE_CONFIRMATION+"',gst_rate='"+gst_Rate+"',is_gstRate_confirmed='"+GST_RATE_Confirmation+"',item_Description='"+ITEM_DESC+"',Unit="+_Unit+"',Qty='"+_qty+"',...
14 Apr 2020 by Member 14639038
i have written the business logic in servlet to update the html table data using jsp. i am giving you the code: BOQServlet package com.mvc.controller; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection;...
6 Apr 2020 by Member 3321282
_ID = Integer.parseInt(request.getParameter("id")); the request.getParameter("id") is not getting a value. this is because the page, i.e. http://server/BOQ-Form.jsp?id= The numberformatexception null is traced to the Integer.parseInt() not...
6 Apr 2020 by Member 14639038
sir I have created jsp page for boq form to update the boq records. i have written the business logic in the jsp page to select the records based on the id first. when i run the this page. then the page showing the ...
19 Mar 2020 by Richard Deeming
You are calling req.getPart("Upload file");, but your has name="file1". I suspect the name passed to getPart needs to match the name attribute on the : filepart = req.getPart("file1"); Also your alternative MIME type is...
19 Mar 2020 by Member 14639038
dear sir, I have written a business logic in servlet : package com.rfmsSite.upload; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.sql.Connection; import...
19 Mar 2020 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
19 Feb 2020 by Richard MacCutchan
You already posted this question at Saving jsp output as pdf[^]. Please do not repost.
1 Feb 2020 by Member 14639038
rfms_excel.java-> package com.rfmsProject.upload; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; import java.sql.SQLException; import java.util.Iterator; import javax.servlet.RequestDispatcher; import...
1 Feb 2020 by phil.o
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FTS, Hospitalityexpense, Krishi_KalyanExpenses, manpowerExpensesContract, Manpow' at line 1 You made a mistake while building your SQL query. And despite...
26 Nov 2019 by Member 14639038
reaadExcelServlet.java package com.mvc.upload; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.util.ArrayList; import...
24 Oct 2019 by Member 12974741
Experts, I have a JSP form page which has Text Area field.I have a string contains 300 lines. when I paste the content in text area field, it accepting the content.but when i submit the form, page got stuck there only and not moving to servlet. If I give less than 50/60 lines....
11 Oct 2019 by JImit Jani
you have to call Servlet from image src in jsp and set var path in QueryString put jsp like this.... servlet code this.filePath =request.getparameter('path');
11 Oct 2019 by Raghavendra M
I am trying to display an image throw jsp. Image is stored in local path so I wrote a servlet get method to retrieve image and in src attribute of image tag I am giving the servlet name and image path as parameter to servlet and here is my code,import java.io.BufferedInputStream;import...
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.
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.
27 Nov 2018 by ruggedtexts
The following code is from this link starting on line 85. I'm a beginner in Java and Google Cloud Storage. I understand all of it except for the second parameter, "file", that is to be the byte array format. If I have a video that is 100GB what would the byte array parameter be? * Uploads...
2 Nov 2018 by Sriyashree Swain
I am a beginner in jsp and servlets. I want to stay in the same page and populate the dropdownlist but iam not able to so. I did it using scriplets and it happened but scriplets are deprecated long back. I just want to know more about servlet mapping in web.xml. I guess something is wrong with...
9 Sep 2018 by Richard MacCutchan
You have spelled it class , but it should be Class with upper case C at the beginnng. See Class (Java Platform SE 7 )[^].
9 Sep 2018 by Member 13977881
C:\J2ee\Servlet>javac RequestServlet.java RequestServlet.java:17: error: expected class.forName("Oracle.jdbc.driver.OracleDriver"); ^ RequestServlet.java:17: error: invalid method declaration; return type required ...
23 Aug 2018 by Patrice T
Never insert data before checking if all fields are ok. String sql="insert into Employee Values ('"+id+"' '"+pwd+"' '"+eAdd+"' '"+gender+"' '"+email+"' '"+lang+"' '"+nation+"' '"+date+"')"; st.executeUpdate(sql); // this line if(id !=null | pwd != null | eAdd!=null |...
23 Aug 2018 by Member 13681858
Quote: i'm trying to insert employee details in sql database but when i run the program it is showing the registration page after entering details output is not showing as blank page What I have tried: web.xml
16 Aug 2018 by Member 9983063
Hello Guys am working on jsp project this project made by my seniors now they left and i really just little bit sound knowledge of jsp please help me when i run this project so am getting this errors please help how can i solve it. HTTP Status 500 - Unable to compile class for JSP: type...
16 Aug 2018 by Jerry Jeremiah
Shouldn't the import of com.apv.erp.resource.DbHandler be com.apv.erp.resource.DbHandler.* and the import of com.apv.erp.resource.PersistenceFactory be com.apv.erp.resource.PersistenceFactory.* ?
9 Aug 2018 by Member 9671810
cannot auto increment id in above code { String sql = "insert into artist_reg_ml (id,uname,pwd,email,country) values (?,?,?,?,?)"; PreparedStatement pst = conn.prepareStatement(sql); pst.setString(1, "5"); pst.setString(2, uname); ...
3 Jul 2018 by MadMyche
request.getHeader("referer");
3 Jul 2018 by Member 13576671
Hello I have a webpage with a forms that when it submits, runs a servlet. In that servlet I need to know the webpage who calls the servlet. How can I do? I´m using Java 8. Thanks What I have tried: I try with several methods of HttpServletRequest, as getQueryString, getServletPath,...
8 May 2018 by khaleelsyed
When i call a EJB method from the servlet page i am getting the following error.. org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [info.java.tips.servlet.MyServlet2] in context with path [/MyFirstWebApplication] threw exception...
6 May 2018 by Richard MacCutchan
String Message = "msg"; /*Set attribute msg of Message*/ request.setAttribute(Message, "msg"); // so the attribute name is "msg" ... String s = "msg"; if (s == request.getAttribute("Message")) // but the attribute name is not "Message" Your attribute names are...
6 May 2018 by shihappns
Function addiFAbssent in class DepartmentBean check if element already exist in container: What I have tried: bool f; public void addIfAbsent(UserBean userBean) { if (users.stream().anyMatch(x -> x.getUsername().equals(userBean.getUsername()))) { f = false; ...
18 Apr 2018 by Nima.hashemian
I am getting a crystal report from the server and I need to save the pdf file automatically into database. How can I get the exported crystal report as ByteArrayOutputStream What I have tried: ReportExportControl exportControl = new ReportExportControl(); ...
30 Mar 2018 by NebroProg
I have : public static void main(String[] args) throws IOException { public void handleRequest(HttpServletRequest req , HttpServletResponse res ) throws IOException { //my code here } } error in public void handleRequest() say the illegal start of the exception What I have tried: ...
29 Mar 2018 by Richard Deeming
First problem: You're trying to UNION two sets with a different number of columns. You can only UNION sets with the same number of columns: MySQL :: MySQL 5.7 Reference Manual :: 13.2.9.3 UNION Syntax[^] I suspect you want to JOIN the tables instead: MySQL :: MySQL 5.7 Reference Manual ::...
29 Mar 2018 by Member 13752376
I am trying to display data from two different database, database1:cover > Table:firmlist database2:userdata >Table:admin How to get database connectivity for two different database? What I have tried:
25 Mar 2018 by NebroProg
I have HttpServletRequest req and HttpServletResponse res wont to use req and res variables in another place in code. and I have another problem in if statement when I was pass function in compression What I have tried: @WebServlet(name = "NaiveBayesExample", urlPatterns =...
21 Feb 2018 by Vignesh Swaminathan
package net.roseindia.handler; import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import...
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...
17 Feb 2018 by Member 13681858
@WebServlet("/PagenationServle...
28 Oct 2017 by Member 13483093
i have a room booking html form if the room and floor is already booked i need to send it errorpage.jsp , itried this using treemap but i dont know how compare the getparam values and map values please tell the syntax What I have tried: package com; import java.io.File; import...
24 Oct 2017 by Member 13483093
i have created login user and password in jsp using textfile (not used database) and i have a form for room booking ,once the room booked by one user it should not be booked by the next user who login the web app .please tell me how to proceed without using database.please help me as im new...
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...
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...
13 Aug 2017 by Member 12324523
In my application I have three listitems File Upload,View Reports and Change Password. I need to hide View Reports if the login is by normal user and i need to display View Reports if the login is by manager. Below is the code of my tabs Code in master page- ...
13 Aug 2017 by Richard MacCutchan
Try using the style attribute, as described at HTML DOM Style visibility Property[^].
16 Jul 2017 by kav@94
I am using a file uploader to choose the file and i need to pass that file path to my servlet dynamically instead of giving the file path statically how can i do this.Below is my jsp code Select File:
5 Jul 2017 by Malshani Wijekoon
Hey Friends, I am doing a java project using netbeans and tomcat. When I run the project it displays following error. ant -f C:\\Users\\Malshani\\Documents\\NetBeansProjects\\E-Learning...
19 Jun 2017 by Member 13267822
https://www.screencast.com/t/5oW3gvU7uopC https://www.screencast.com/t/4Va3xFYZB https://www.screencast.com/t/XBEq37HL1MV What I have tried: I have created a demo servlet.and it is maven project.But i am getting http 404 error.
13 Jun 2017 by Venkatesh K H
I have stored email, dob, first name and last name in the database. Now i want to make password creation. In login page first time user should create password and it should store in the db. Again if the same user logs in with correct credentials, it should redirect to landing page. But there are...
2 Jun 2017 by Member 13237265
Quote: i have 2 html pages.retrieve data from both and display on other servlet page.And i having a button redirecting to first html and re-entering the data again .second given data will be show below first given data , automatically in servlet page How it can be possible i tried with...
27 May 2017 by Member 12974741
Appreciate if someone could assist me on this.... i have a servlet coded already (Its a http url). I would need to access the servlet in JSP to get the data using ajax. can someone tel me how to obtain this? url link below is given for sample.... $.ajax({ type: 'GET', data : { }, url:...
7 May 2017 by SanketAB
I am developing simple Dynamic Web Project. Env details: Eclipse-Kepler (Java 1.6) with apache tomcat 6.0 server. My project structure is as follows: Under WebContent/jsps folder i have: home.jsp listcenters.jsp center.jsp Under /src/com/myexample/controller i have: CenterController.java...
16 Apr 2017 by Bryian Tan
It should be width:90px, not width=90 out.println(""); Example[^]
16 Apr 2017 by Member 13092275
hi, i am using serlvet and i need to know how to wrap a cell contents to a cell width without using CSS. i need to achieve this directly through the td tag. What I have tried: out.println(""); out.println("
15 Mar 2017 by Member 13060088
Hello,I am designing a webapplication using Eclipse Luna for programming and SQL for database.I stuck somewhere in code but cant get it done after so many trials.I attach hereby my code and jsp page too. I do get the data which i required to display but the problem is, for each new input...
1 Jan 2017 by kksoftskill
How do I track the user activity and timing on video portal using JSP and Servlet?What I have tried:How do I track the user activity and timing on video portal using JSP and Servlet?
24 Nov 2016 by markkang
In this article, I will introduce how to call RESTful API in servlet.
2 Sep 2016 by ShaktisinhRathod
Dear Experts,Tool used : JavaSteps1)Generate PDF (using jasperireport 3.6.1) java2)Store On Server3)Apply digital signature on stored server4)Ready for download on page.code below protected void processRequest(HttpServletRequest request, HttpServletResponse response) ...
28 Jun 2016 by Member 12608069
>>using servlet,jsp>>first register with username and password>>after login with that username and password>>wihtout database>>tools::in ecalipse ide.>>please help me >>with database we need to create a table like username,password>>after we will get like this connection=new...
6 Jun 2016 by Member 12569519
how to retrieve data from database and display it in table with edit,delete option? using (jdbc servlet html css)What I have tried:using jdbc and servlet I can fetch the data but unable to form it in table and add edit,delete option.
6 Jun 2016 by George Jonsson
You could try to use AngularJS. Here is one starting point out of many:AngularJS Tutorial[^]And this one Angular JavaScript Framework: Interacting with Java Servlet Backend[^]
14 May 2016 by Member 12524018
I am calculating the price of a ticket with discount on weekdays and weekends based on the time duration.So, i gave inputs of duration and date using datepicker plugin which is in Above Page. For this i am getting proper result.But i have to create two different jsp pages(date.jsp and cal.jsp)....
14 May 2016 by Sergey Alexandrovich Kryukov
Probably you can received detailed answers based on session and specific to JSP.I want to suggest more universal and modern alternative based on Web storage. This approach is agnostic to the server side; it can even work without any server side at all, when you simply want to restore some UI...
11 Mar 2016 by ashwin subramanya
Im developing Java EE 8 application which makes use of BIRT to generate a pdf and send it on to client. But i want to add the data received from the request directly to the generated pdf ie without adding them to a database(so i cannot add the values by binding data source).These are...
12 Feb 2016 by Skynet_Code
Hi.To avoid spending much more time while maintaining your code than developing it, you should thing in a MVP arch. Start by developing, for example, a servlet (Controller) that uses a wrappered Java (Bean) class (Model) to get data from DB. Later, in your JSP (View) you can ask controller...
12 Feb 2016 by mong220394
I am trying to avoid java code in jsp file. but i couldnt figure the solution. so i ended up mixing the codes :( how can i divide this code? PLEASEEE HELPPP...Thank you very much.What I have tried:
28 Jan 2016 by Richard MacCutchan
Then please use Google to search for it. This is not a code-on-demand forum.
28 Jan 2016 by Richard MacCutchan
Using Google to do your own research is generally considered a good idea.
13 Jan 2016 by nashwa_ahmed
adding library (mysql-connector-java-5.1.38-bin.jar) to the project
12 Jan 2016 by Richard Deeming
nashwa_ahmed wrote:the validation class return false foreverThat's hardly surprising - based on the code you've posted, you declare a variable called st, initialize it to false, execute a query, and then return the value of st. You never update the value of the variable, so the method...
12 Jan 2016 by nashwa_ahmed
Dears,I face a problem in accessing DB from servlet but i din't catch the error, so kindly any help.------validation.java--package register;import java.sql.*;public class validate { public static boolean checkUser(String name,String pass) { boolean st...
7 Jan 2016 by Member 12115837
use onchange onchange="document.getElementById('e').hidden=1;document.getElementById('d').hidden=0;document.getElementById('b').checked=0;" value="x" id="c">x
12 Dec 2015 by Member 9671810
hello,I am passing username using session in other page. but to redirect that page i am using session. but after i login username and password is seen on the url. How to decode it? HttpSession sess = request.getSession(); // if(sess != null) ...
27 Nov 2015 by Khalida Mujahid
I am new to Java programming & in a project I want to upload CSV file using JSP and servlet save into Java DB.... Also there is a requirement that we don't know the size of file & number of columns & rows in advance before uploading file So, code for reading columns from file would be...
26 Nov 2015 by Member 11944583
If i try to read checkbox status from checkbox.html file after clicking the button instead of getting the values of checkbox it is downloading file which contains the status of checkbox.what i need to do solve this problem.Here my checkbox.html file code:
10 Nov 2015 by Siddharth.10
How do I change drop down list content based on radio button click. my code :import java.io.IOException;import java.io.PrintWriter;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import...
10 Nov 2015 by Siddharth.10
How do I change drop down list content based on radio button click. my try : http://ideone.com/RWbZ54import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import...
26 Oct 2015 by Member 9671810
this is my code for searching. But i want to print it on jsp page, cause i have used jquery for gui.try{ Class.forName(driver).newInstance(); con = DriverManager.getConnection(url, "root", "root"); // String sql =...
26 Oct 2015 by Luis Carlos Gonzalez Barcenas
When you click any of the buttons the servlet will call the doPost or doGet method specified by you in the form. ......As the two buttons have the same type submit and I suppose that are into the form, any of your action...
26 Oct 2015 by Luis Carlos Gonzalez Barcenas
The tag must have a value, example Option1 Option2 Option3
24 Oct 2015 by Member 9671810
here i want the dropdown's selected text. i tried using this but it just gets null value. String [] drpdownvalue = request.getParameterValues("drplistalbum");and i have made a dropdown like thisout.println(""); for(String name...
24 Oct 2015 by Member 9671810
this is my submit button.. i want to use other servlet for handling this servlet here it can call a .jsp page but it cannot handle servlet
22 Oct 2015 by Member 9671810
there are two buttons in my jsp page1. Album Name ...
21 Oct 2015 by Member 9671810
try this.. it works{ PreparedStatement pst1 = conn.prepareStatement("select max(id)+1 from artist_reg_ml"); ResultSet rs = pst1.executeQuery(); String user_id ="" ; while(rs.next()) { user_id =...
21 Oct 2015 by Richard MacCutchan
See https://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html[^].