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

  • SEARCH
  • Home
  • 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 5998807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:27:30+00:00 2026-05-23T00:27:30+00:00

I have a simple servlet at the moment. I need it to call a

  • 0

I have a simple servlet at the moment. I need it to call a static jar method and return its response.

1) Can someone recommend a suitable structure ie do I need to create factories and handler classes etc…

2) How should I encode the hash in the response … Is the simply writing to output stream ok do something else ? Ie write to headers etc.. Another App will be reading the response.

3) Not sure about handling nulls etc..

package myproj.servlet;

//Std imports
//Serlet imports
import myproj.hash.HashGenerator;

public class MyServlet extends HttpServlet{

String hashcode;

protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    String accountName = req.getParameter("accountName");

    try {
        hashcode = HashGenerator.hash(accountName);
        resp.setContentType("text/plain");
        PrintWriter out = resp.getWriter(); 
        //[EDIT] was returning accountName by accident
        out.print(hashcode );

    } catch (Exception e) {
        //Some logging code
    }

}
  • 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-05-23T00:27:31+00:00Added an answer on May 23, 2026 at 12:27 am

    First and foremost, your hashcode is not thread-safe.

    1. After looking to your provided snippet. I don’t think so. It is fairly simple thing.

    2. You are getting accountName as parameter, and then writing the same back. Is that you want? Or you mean respond the hashed version.

    3. You might like to validate accountName parameter, since it is the input provided by user.

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

Sidebar

Related Questions

I have a simple jsp/servlet application and I want to add AJAX feature to
I have simple static lib in xcode with the only class test.h: @interface TestClass
I have simple regex \.*\ for me its says select everything between and ,
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have a simple servlet running in Tomcat. Because the servlet connects to a
I have a simple (Servlet, JSP, and JSTL) web app whose main functionality is
Let's say I have a simple Login servlet that checks the passed name and
I have a simple servlet where I write to a file if it has
I have a pretty simple JSP/Servlet 3.0/Spring MVC 3.1 application. On one of my
For a customer, I need to write a Servlet which can print values in

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.