seetaram
servlet doubt
1 Answer(s)      5 years and 2 months ago
Posted in : Servlet Interview Questions
How do I read and output a text file from a Servlet?

How can I invoke a servlet from JavaScript?
Advertisement
View Answers

March 22, 2010 at 12:02 PM


Hi Friend,

Invoke servlet from javascript:

1) create jsp file and put the following code:

<SCRIPT >
function load(){
window.location.replace("http://localhost:8080/examples/Servlet";, "subWindow","height=500,width=700,resizable=yes,scrollbars=yes");
}
</SCRIPT>
<body onload="load();">

2)Servlet.java

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Servlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException{
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}

To read file from a servlet, go through the following link:

http://www.roseindia.net/servlets/servlet-read-file.shtml

Thanks









Related Tutorials/Questions & Answers:
Doubt in servlets - JSP-Servlet
Doubt in servlets  Good Evening sir/madam, I want to add data dynamically for that which methods i have to use to retrieve the dynamic data .  Hi Friend, Try the following code: 1
servlet doubt on online examination system
servlet doubt on online examination system  hai. sir ,i am doing... the programs using java servlet. MY PROBLEM and doubt is 1. how 2 skip.... plz provide us code in servlet sir. its very urgent sir  plz can
Advertisements
servlet doubt - Servlet Interview Questions
servlet doubt  How do I read and output a text file from a Servlet? How can I invoke a servlet from JavaScript?  Hi Friend, Invoke servlet from javascript: 1) create jsp file and put the following code
Clarify my doubt - JSP-Servlet
Clarify my doubt  Hi All, Although i know the concept of Servlet & JSP, but I have never got a chance to work in EJB . So could u please tell me how... project in netbeans adding jsp/servlet in this web project and deploying
doubt this
doubt this  what is the use of "this" and "super" keyword
DOUBT ?
DOUBT ?  in c++ member function of a class must be public
Doubt
Doubt  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details
Doubt
User request form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
How to load page  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action="page2.html
Doubt
Submit and process form  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
Doubt
load next page after submitting  how to submit the details and how to go the next page after submitting.please clarify my doubt I don't know how to submit details.   1)page1.html: <html> <form type=get action
Doubt in using combination of JSP page and Java class. - JSP-Servlet
Doubt in using combination of JSP page and Java class.   I've got a drop down list and a table of 2 rows and 2 columns with a button in each cell... youfor replying. I didn't used struts,insted i went with servlet and Java Class
Validation doubt
Validation doubt  hi..... thanks for the other validation code. I have got that and implemented in my code but i have a doubt in that. As we try... think i am able to tell u what i want to and u have got whats my doubt. plz give
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how to integrate struts with hibernate,any predifined plugin is available or we need to create our own plugin????? and please help me. how to use dao s while integrating
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how to integrate struts with hibernate,any predifined plugin is available or we need to create our own plugin????? and please help me. how to use dao s while integrating
java beginners doubt!
java beginners doubt!  How to write clone()in java strings
doubt about J2EE connetivity
doubt about J2EE connetivity  steps to connect J2EE components with MYSQL
doubt in struts - Struts
doubt in struts   i don't understand the concept on Resource bundle in struts can u please help me out
doubt regarding JSF
doubt regarding JSF  Hi, pls explain what is difference between struts &JSF? pls explain what is difference between SPRING &JSF
String doubt replace function
String doubt replace function  What is the output and why of below : String s1 = "Hello"; if(s1.replace('H','H')== "Hello") System.out.println("yes"); else System.out.println("No"); if(s1.replace("H", "H")== "Hello
Doubt Regarding Charts
Doubt Regarding Charts  Hi, Can you please help me out by answering "hoe to include charts in core java code and struts code" thanks in advance, Swaroop Eswara   Please visit the following link: Jfreechart
"Doubt on Swing" - Java Beginners
"Doubt on Swing"  Hi Friend.... Thanks for ur goog Response.. i need to create a GUI Like... pic1.gif RadioButton pic2.gif RadioButton Pic3.gif RadioButton If we have select d appropriate radio
DOubt in Mysql connections
DOubt in Mysql connections  i have some problem regarding data base connections, i have created a hostname, username and password in filezilla server but after i give those names also it is showing error like this: mysql