reset password
Author Message
Fatemah
Posts: 59
Posted 19:43 Jan 29, 2012 |
I have some questions regarding homework 1:
 
1- Do I need only servlets for all of the pages?
 
2- How many servlets and HTML pages are there in homework 1? And if there is any HTML page, what is it for?
 
3- In the page that is for creating a new not existing page, where the user should enter his name and some contents, when the user clicks on “Create” button in order to be directed to his new page, nothing happens. I used request.getParameter(“name”) and it doesn’t display the name nor the content. Why is that?
 
4- For the date, do you want it to be displayed the way is shown in the video? How do I make it be shown like that? what is the method?
 
5- What do you mean by Java API Documentation? Is there an extra credit on that?
YangXuan
Posts: 23
Posted 20:39 Jan 29, 2012 |
Fatemah wrote:
I have some questions regarding homework 1:
 
1- Do I need only servlets for all of the pages?
 
2- How many servlets and HTML pages are there in homework 1? And if there is any HTML page, what is it for?
 
3- In the page that is for creating a new not existing page, where the user should enter his name and some contents, when the user clicks on “Create” button in order to be directed to his new page, nothing happens. I used request.getParameter(“name”) and it doesn’t display the name nor the content. Why is that?
 
4- For the date, do you want it to be displayed the way is shown in the video? How do I make it be shown like that? what is the method?
 
5- What do you mean by Java API Documentation? Is there an extra credit on that?

 For question 1 and 2, the design for servlet is up to you. You can also get the HTML source code in the HW1 page, just right

click on the page and then choose to view the page source code.

3 - In order to use the request.getParameter("name"), you should use the form in the create page. Check out the Edit Entry in

GuestBook for detail.

4 and 5: Java API Documentation is a source code based specification intended to be used as an interface by java

components to communicate with each other.  You can use the Java API Document to help the java development.

Check out the SimpleDateFormat on java API Documentation to solve the date display problem. 

Last edited by YangXuan at 20:41 Jan 29, 2012.
Fatemah
Posts: 59
Posted 20:50 Jan 29, 2012 |

It always gives me :

java.lang.NullPointerException

when I try to display name and content .. why is that ?

 

I used request.getParameter(String str) to access name and contents from the html code but it always gives me null!!!

How can I fix this?

Last edited by Fatemah at 20:51 Jan 29, 2012.
YangXuan
Posts: 23
Posted 21:01 Jan 29, 2012 |
Fatemah wrote:

It always gives me :

java.lang.NullPointerException

when I try to display name and content .. why is that ?

 

I used request.getParameter(String str) to access name and contents from the html code but it always gives me null!!!

How can I fix this?

It is hard to tell without seeing the code. Two things you can pay attention:

1. the method = "GET/POST" in the form should be matched to the proper servlet's  "doGet" or "doPost" method.

2. the string in the name attribute in <input type='text' name='XXX' /> should be as the same as in the request.getParameter("XXX") (notice that the XXX is double quoted as string in the getParameter() )

Last edited by YangXuan at 21:02 Jan 29, 2012.
Fatemah
Posts: 59
Posted 21:09 Jan 29, 2012 |

I did all of this.

[code removed by cysun]


But I still get this error. When I try to display the contents using out.println(

Last edited by cysun at 07:46 Jan 30, 2012.
YangXuan
Posts: 23
Posted 21:32 Jan 29, 2012 |
Fatemah wrote:

I did all of this.

 

[code removed by cysun]


But I still get this error. When I try to display the contents using out.println(

It seems that you could get the values from name and content variables. The problem is in entries.add(entry). It could be

something wrong with entries object stored in the servlet context container. You can use the debug tool in Eclipse to check the

entries object. 

Last edited by cysun at 07:46 Jan 30, 2012.
Fatemah
Posts: 59
Posted 21:34 Jan 29, 2012 |

Finally, I solved it


Thank you so much

Last edited by Fatemah at 21:35 Jan 29, 2012.
cysun
Posts: 2935
Posted 07:53 Jan 30, 2012 |
Fatemah wrote:

Finally, I solved it


Thank you so much

Fatemah, first of all, posting complete source files (or large part of one) in the forum is prohibited. I have removed the code you posted.

Secondly, this is a homework, and design and debugging are part of the work. Sherry and I can give you some general instructions, but ultimately it is your responsibility to figure out how to structure the application, write the code, and make it work.