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 8809129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:47:39+00:00 2026-06-14T02:47:39+00:00

I have a form in search.jsp <s:form name=employeeSearchForm action=searchAction method=post> <s:textfield name=id label=Employee ID/>

  • 0

I have a form in search.jsp

<s:form name="employeeSearchForm" action="searchAction" method="post">
    <s:textfield name="id" label="Employee ID"/>
    <s:textfield name="name" label="Employee Name"/>
    <s:submit/>
</s:form>

In struts.xml

<package name="example" namespace="/" extends="default">

    <action name="searchAction" class="example.SearchAction">
        <result>/example/search.jsp</result>
    </action>

</package>

Then the SearchAction class

public class SearchAction extends ActionSupport {

    private String id;
    private String name;

    @Override
    public String execute() throws Exception {

        if ("".equals(id.trim())) {    //#1

        ...

    }

    ...
}

See the #1 line code, if I clicked submit button from the Form in search.jsp, the id field will not be null, but if I open http://127.0.0.1:8080/myapps/searchAction.action directly, id field will be null.

In this case, I can use field check in SearchAction.exeucte(), e.g. if (id != null) , but I doubt if it’s the most elegant way.

Anyone can suggest better way?

  • 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-14T02:47:41+00:00Added an answer on June 14, 2026 at 2:47 am

    private String id=""; \quick fix.

    But app shouldn’t allow the user hitting the action directly user should be authenticated and/or authorized before.

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

Sidebar

Related Questions

I have a form that looks like: <form action=search.php method=post> <fieldset> <label for=level_one>Main category</label>
Ok so i have a form <form action=/search method=post> <input type=hidden name=location_id value=1 /><br
I have the following form from http://regain.sourceforge.net/ : <form name=search action=search.jsp method=get> <p class=searchinput>
I have a form in my master page declared: <form name=search method=post action=searchresults.aspx id=searchform
I have form like this: <form method=POST action=<?php echo base_url() ?>admin/admin_search> <fieldset> <label for=nalozi>Nalozi</label><input
I have a form, as such <form action=search.php method=get id=search> <input type=text name=first_name/> <input
I have a form like this: <form action=search.php class='search' method='GET'> <input type=text/submit class=home_search_area value=Search
In one page I have two form for search: <form class=search-panel method=post action= onsubmit=return
I have a simple search page with this text input form <form name=assetInput action=assetResult.jsp
I have a form object with a form like : <form:form commandName=search id=xmsimplify-form method=POST>

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.