asaf shay

Greenhorn
+ Follow
since May 18, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by asaf shay

Bear Bibeault wrote:You should not any have variables or any other code in the JSP page. Perform the data handling in the servlet controller. Keep track of what "page" you are on using a hidden variable in the form.



1)i have a list that come from the servlet ,i need to print this list how can i do that if not using inside the jsp ?

2)"Keep track of what "page" you are on using a hidden variable in the form" i do not know which way you go


my solution is to save in session the index and For example if the user click the page 2,i send to servlet the number 2 and he will change the value that i store in session that track the index . and the user
will be in the same page but now the page print the coupons from the new index .Is this idea right ?
8 years ago
JSP
After I tried a few things and I failed I decided to try a session, I guess it will work. Anyway thanks helpers.
8 years ago
JSP
I could not solve the problem and I'm at a loss

i have coupns list . i want to create in the bottom page number . in every page i define to have 3 coupon Maximum."every page" i mean it's the same page !!
i just want to change the index from where to start to print the coupons.


i try to create static variable
<%! static int indicateFromWhereToStartPrint = 0; %>
and the pages numbers i create like this
<a href="#" onclick="goToPage(2)">2</a>
i did this for every page .
in the function i increased if necessary the indicateFromWhereToStartPrint , the problem is the variable is incress even when i do reresh to the page
8 years ago
JSP
i have jsp file and inside i have list that i get from my servlet .
i want to create in the bottom of the page the option to move from one page to another like this " page: 1,2,3,4,5"
i try to use the tag <a href=.. and onclick() event ,and i understand that javascript will not work ,

someone know how can i create the " page: 1,2,3,4,5" ?
8 years ago
JSP

Bear Bibeault wrote:

asaf shay wrote:1)I told you that if I want a user saves to Favorites Result of seraching by some thing i have to know the query string and from that i know what he searching for


That still does not mean that the name of a JSP needs to be used in the URL. Why do you think you need a JSP name? Any URL that gets the info can be bookmarked.

2)Apparently we have a misunderstanding ,the file bla.jsp in the WEB-INF


I can barely see the text in the video, but I do not see where WEB-INF is any prat of the url or path.

WebContent is not WEB-INF.



about the second part i now understand what you saing and i will check it .

1)i use the query string like i said , is it bad programing ?

last Question so if i want to open index.jsp (this is my starting page) i will redirect like this
http://localhost:8080/MiniCouponsWebsite/ServletName/welcome

is it good to leave the name of the servlet in the address ?
8 years ago

Bear Bibeault wrote:

asaf shay wrote:1)if you don't let the user the option to save to favorite you limit him .and in my site i don't want to limit .


Please show me where I said you should not allow bookmarks. I never said that. Anywhere.

I said you do not need the name of the JSP to create bookmarks. You can bookmark any URL.

2)i just upload to youtube how i can,i put file under WEB-INF that call bla.jsp and i open it /


That video does not show anything being accessed from inside WEB-INF.



1)I told you that if I want a user saves to Favorites Result of seraching by some thing i have to know the query string and from that i know what he searching for .

2)Apparently we have a misunderstanding ,the file bla.jsp in the WEB-INF and I managed to open so i don't know what else to say it's also in the video You can clearly see
8 years ago

Bear Bibeault wrote:1) No, you do not need to bookmark JSP files. In fact, you should not. A JSP without its page controller makes no sense. You should create URL mappings that make sense. JSP names should never be part of a URL.

2) Wrong. You cannot open a JSP that is under WEB-INF by using a URL in the browser.



1)if you don't let the user the option to save to favorite you limit him .and in my site i don't want to limit .

2)i just upload to youtube how i can,i put file under WEB-INF that call bla.jsp and i open it /


8 years ago

Bear Bibeault wrote:Your second url is not the correct way. The URL should be to the servlet page controller and not even mention the JSP. Who cares what the JSP is named? The end user sure doesn't.

See this article if this pattern isn't familiar.

To prevent JSPs from being directly navigated to, they are placed somewhere under WEB-INF. This prevents them from being directly served, but allows page controllers to forward to them.



1)to open index.jsp i agree with you that the end user don't care about the jsp file name but !! ,i build coupons site and one of the option is to let pepole to save to favorite there search result for example to see coupon by specific town , if i want to navigate when he open the link from the favorite i need to let him save querystring and i will navigate him when he return the next time.so it's not always true that the user don't need to know the jsp file , becouse as i explain i want to know.

2)to put file under WEB-INF not prevents anything ,i can still open the file directly
8 years ago

Bear Bibeault wrote:You asked how to make sure that using the URL with no path goes to the right place. The welcome list in web.xml tells the app what to do when there is no path. By default, it first goes to index.jsp. You change that behavior in web.xml.



it's not what i"m asking but thanks anyway about the info you give me .

there is two way to open a file : for example index.jsp
first this how i open until now)
http://localhost:8080/MiniCouponsWebsite/index.jsp
meaning not Through the servlet
second : (that Through the servlet )
http://localhost:8080/MiniCouponsWebsite/ServletName/index.jsp

How can I ensure that if someone tries the first way he would be redirect to the second option ? correct me if i Wrong Through session ?

8 years ago

Bear Bibeault wrote:You can make the url of the page controller for the first page an entry in the welcome-list in web.xml.



Maybe I did not understand your answer, but I did not understand how it helps me ?
8 years ago
meaning if i have website test.com and i want to open my first page .

i need to make shure that if i insert in the address bar www.test.com ,i need to redirect to www.test.com/servletName/index.jsp ??
8 years ago
i call him from my index.jsp .

I'm more interested to call the index.jsp from servlet this will solve the problem .i try couple of things and go back if have problem
thanks
8 years ago
but the problem is that i"m talking about the first page index.jsp .and he the onlyone from other pages that doesn't go Through the servlet
8 years ago
i have file index.jsp , that approach to reguar java class and call function . in that function i want to get attribute from session like this :

List<Coupon> couponsList = (List<Coupon>)request.getSession().getAttribute("listOfCouponsThatNotExpired");

because this regular java class i get error message , someone know how to solve this ?
8 years ago