473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

how print hindi text into web page by given servlet code

i am using one servlet file, one java file, one html file as given below:

//Extraction1.java //java file
Expand|Select|Wrap|Line Numbers
  1. import java.io.IOException;
  2. import java.net.URL;
  3. import java.util.Scanner;
  4.  
  5. public class Extraction1 {
  6.  
  7.     public String toHtmlString(String url) throws IOException 
  8.     {
  9.         StringBuilder sb = new StringBuilder();
  10.            for(Scanner sc = new Scanner(new URL(url).openStream()); sc.hasNext(); )
  11.               sb.append(sc.nextLine()).append('\n');
  12.            return sb.toString();
  13.     }
  14.  
  15.  
  16. }
  17.  
//MultiParamServlet3.java // servlet file
Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. import javax.servlet.*;
  3. import javax.servlet.http.*;
  4.  
  5. public class MultiParamServlet3 extends HttpServlet
  6. {
  7.     private static final long serialVersionUID = 1L;
  8.  
  9.     public void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
  10.     {
  11.             PrintWriter pw=resp.getWriter();
  12.  
  13.             resp.setContentType("text/html");
  14.  
  15.             String[] values=req.getParameterValues("habits");
  16.  
  17.             Extraction1 t=new Extraction1();
  18.             String s=t.toHtmlString(values[0]).replaceAll("\\<.*?>","");
  19.             pw.println("<html><head><meta charset=\"utf-8\"></head><body>"+s+"</body></html>");
  20.  
  21.               pw.close();
  22.     }
  23. }
  24.  
//index.html // html file
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Insert title here</title>
  6. </head>
  7. <body>
  8. <form method="Post" action="MultiParamServlet3">
  9. <Label> <br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter the URL :  </label>
  10. <input name='habits' id='t2'>
  11. <input type="submit" name="submit"> 
  12. </form>
  13. </body>
  14. </html>
  15.  
Servlet program able to print English text after extraction, but Hindi text converted as ????? (question mark).

If we enter URL as : "https://hi.wikipedia.org/wiki/%E0%A4%B5%E0%A4%BE%E0%A4%B0%E0%A4%BE%E0%A4%A3%E0%A 4%B8%E0%A5%80"
how do print Hindi text into web page by servlet program ?
Feb 21 '17 #1
0 1179

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Melissa | last post by:
I have a report that groups by customer and creates a new page for each customer. I need to programatically print different text in the page footer of each page. What code do I need to do this and...
0
by: magic man | last post by:
I have written an application in VB.Net using server side controls. I realize that I need client side controls to print anything at the clients computer. I have a web page that consists of a 1...
0
by: tpal | last post by:
I need to save the hindi or any other regional language text in the database. i have oracle database and the field in which i want to save ha datatype CLOB. I am using Infragistics HTML editor so,...
3
by: mygroup | last post by:
Hello Folks, I have an asp.net application which requires to fill a form. Once the form is completed, it should print the final page on server side (not the client side). I tried to use...
2
by: Nilanjan Sanyal | last post by:
how to retrieve hindi text from mysql database using php
0
by: Rimple Saini | last post by:
Respected Sir/Mam I have an *.Fla file(action script file) can u just tell me that how Fla file will support hindi text.
1
by: remya1000 | last post by:
I’m using VB.Net 2008 application program. I’m using DataGridView. I have a Print option where i need to print the DataGridView. I’m using this code for Printing and for Print Preview. ...
1
by: shyam123 | last post by:
How to print hindi word using java
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.