Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9233295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:31:11+00:00 2026-06-18T06:31:11+00:00

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method

  • 0
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws     ServletException, IOException {
    // TODO Auto-generated method stub

    try {
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("/home/ahis/Desktop/outfilename.txt", true)));
        out.println("the text");
        out.close();
    } catch (IOException e) {

    }

I have the above code for writing text to the file.I need to get this data from file and need to set this value as the content of theTextBox.

I have the following jsp file.

         <%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%>
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"    "http://www.w3.org    /TR/html4/loose.dtd">
 <html>
 <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form method="GET" action='Controller' name="good">
<input type="submit" name="submit" value="submit">
<input type="text" name="done"> 
</form>
</body>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:31:12+00:00Added an answer on June 18, 2026 at 6:31 am

    Add this code into servlet For accessing data from file

     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws     ServletException, IOException {
        // TODO Auto-generated method stub
    
    String TextValue=null;
    try {
             File file = new File(fileName);
             Scanner scanner = new Scanner(file);
             while (scanner.hasNextLine()) {
               if(TextValue==null)
              {
               TextValue=scanner.nextLine();
              }
              else
            {
               TextValue=TextValue + " "+scanner.nextLine();
    
            }
    }
                 scanner.close();
               } catch (FileNotFoundException e) {
                 e.printStackTrace();
               }
    
    request.setAttribute("TextValue",TextValue);
    
    }
    

    And changes in JSP file are

    <form method="GET" action='Controller' name="good">
    <input type="submit" name="submit" value="submit"/>
    <input type="text" name="done" value='<%=request.getAttribute("TextValue")%>'/> 
    </form>
    

    Hope this will help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { URL url = new
I have the following doGet() : protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
My servlet function looks like these: CODE: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
I'm new to servlets, I have question in HttpSession, protected void doGet(HttpServletRequest request, HttpServletResponse
I have this servlet: public class SaveImage extends HttpServlet { protected void doGet(HttpServletRequest request,
Can anyone take time to convert this into ASP.NET?Please.. protected void doGet(HttpServletRequest request, HttpServletResponse
import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest;
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.GetLeft.Value = invited.GetInviteCountByWeb().ToString(); HttpCookie
protected void LoginCheck() { if (Session["Login_Status"] == null || Session["Login_Status"] == "false") { MessageBoxShow("Please
protected void Button3_Click(object sender, EventArgs e) //export { GridView2.AllowPaging = false; GridViewExportUtil.Export(Сводка.xls, this.GridView2); GridView2.AllowPaging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.