Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How resolve ? Servlet

 
Isabella Wavrinka
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I'm working in project, but I'm never working with servlet before and I have problem.
I need create website with Form when you can write information and after that display data. So it works. But the problem is the user not know how to filter data to display after:
So I have to firstly display data from Database ( Names, data such as Time, name of images etc.) and after that in Form or something give the opportunity for the user to get data which he want to read. For example only:
I have in Database Names and user not has to be know how they call, what's their names. He only wants data which attached to their people like: their favourite books etc..
It is possible to do in servlet ? I can create Form in html+Css but only what i can do its give to user write something data (like input) and after that go to the servlet and read data from the Form. And that's all.
I read also and maybe i should look on java servlet pages ? Please for comments or advice.
 
Isabella Wavrinka
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To sum up:
I have to download data from the Database and display it in Form, and by choose from the list: for example Richard books: display in servlet.
Actually I have Form in html and I have to know that in Database is person like Richard. But its not what i wanted. Im very sorry if I wrote mistakes languages.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to proceed in a methodical step by step fashion - trying to go directly to the final product will result in chaos.

Without knowing more about your working environment and background, I can only suggest:

1. Get a Tomcat server working on your system.

2. Compile and run some of the servlet and JSP examples provided with Tomcat. Try modifying some of the simple examples to see what happens.

3. Try creating HTML pages with the elements you need - form, list, etc - as static HTML if you are not already comfortable with HTML.

4. Get an example of the database retrieval you need as a stand alone program - possibly with command line input.

5. With all that as a base you can think about organizing your final product.

6. This is just my opinion but - I would avoid trying to use something like Eclipse  to organize the project, IDEs tend to do stuff behind your back. See the forums here for problems people have had.

Bill
 
Isabella Wavrinka
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm actually using server:Tomcat, and programming in Eclipse.
I create own Form where user can write input data in parameter, and on servlet side: request.getParameter("Parameter");
But i have to create something website where user can choose what data neet to display and i dont know how to do this in servlet. Is it possible ?
I read toutorials servlet, but they only show POST,GET method where i should display something data from Database, but they show FORM where i have to write manually data, but what when i dont know what exactly write in FORM parameter before servlet open ?
To be honest i never use .jsp, but if you tell me that i should learn this because there i find solution or where i should go it will be very good help for me.
input.png
[Thumbnail for input.png]
 
Alexander Brank
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

First thing for the view you got to use JSP (JavaServerPages).

There you enter data in standard html form with attributes form action ="servletUrl" and method="POST/GET".

How do you interact to the database with JDBC, JPA/Hibernate?  It is hard to answer without knowing your application structure.

In servlet

request.setAttribute("catalogId"); //java list

In JSP:

using JSTL/EL:

for example:

<select name="catalogId">
    <c:forEach var="catalog" items="${catalogId}">
        <option value="${catalogId.key}" ${catalogId.key == catalogId ? 'selected="selected"' : ''}>${catalogId.value}</option>
    </c:forEach>
</select>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic