swarna dasa

Ranch Hand
+ Follow
since Mar 15, 2007
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 swarna dasa

i think they have action errors n field errors

<s:actionerrors/>
<s:fielderrors/>
16 years ago
I am trying to render a radio button, such that they appear one below the other (top-down). [Using a static map]

<s:radio name="serverGroup" value="Single Server" list="#{'singleServer':'Single Server','redundantServer':'Redundant Server'}"/>

We have an attribute requiredposition which takes values right or left, how do i display them one below the other?

http://struts.apache.org/2.x/docs/radio.html

Also, i am trying to preselect the first option but am not able to

Also a colon is displayed (If i have a label then that label is displayed before the colon)



Required output



Any help would be appreciated.
16 years ago
I am not too sure if i understand your question correctly, but here is an attempt to answer

You said you are not using a tag handler, so you don't have a tag-class, so i assume you must be having a <filename>.tag under WEB-INF/tags.

The developer can get the attribute information from the tag file itself
<%@ attribute name="attr" required="true" rtexprvalue="true" %>.

TLD lets you mention the location of your tag file (but thats just the location)


<tag-file> tld element has the following attributes

description
display-name
icon
name
path
example

As you can see there is no place for attribute which is available in the tag tld element.

Further reading
Tag Library Descriptors
An Add-on

In the above jsp if we have a c:set without value, then only the pagescope is affected


Output is

><
>request<
>session<
>application<

if value is not provided then is the value considered to be an empty string as against null?
Thanks for your input.
Guess one can't add values to a requestScope map, so that fails.

Added the map to the page scope in the scriplet and now it works fine
pageContext.setAttribute("map",map);

Thanks again.
Thanks!!! Should have looked at the API docs
Thanks though!!!
Reference HFSJ Pg 445

"If the value of the object is null, the attribute is removed. (If scope is not specified it will start looking at page, request, and so on)"

Now if it does find an attribute at page level, i thought only the page level attribute is removed.

It came as a surprise to me that the attribute at all levels is removed.



Output
Print set values
>com.example.bean.MyBean@8fbecf<
>request<
>session<
>application<
Print new values
><
><
><
><

Is this a bug or it is supposed to work this way?
Using Tomcat 5.5.23
I am trying to use c:set with a map and i get the following error



The error is caused due to the following lines in the jsp (line 1 and line 2)




Seems like i am missing some very basic concept in JSTL.
Any help would be appreciated.
Guess am a little lost

If cookies enabled, then The Session is valid in the new Window.
if cookies are disabled and url rewriting is used, then The Session is valid in the new Window.
If cookies are disabled and url rewriting is NOT used, then The Session is not valid in the new Window

Nothing was mentioned in the above question, in that case, what are the assumptions made?

Also, is my understanding right?
Did you have a package statement in your data.java file?
If no, then your data class doesn't have a package (it has a default package)

Remove the line
<%@ page import="data" %>
and you should be fine.
String could be "1234"

so you could say request.setAttibute("1234",p);

but with dot operator, 1234 is not a valid java identifier, so you cant say
pageContext.request.1234 //wrong

can say
requestScope["1234"]
or
pageContext.request["1234"]
Thanks for the reply.

I think i misunderstood URL rewriting.
I thought that even if i open a new window and say "http://localhost:8080/webapp/Result.jsp" i would get the old session.
It is just that when i try to open the url, pointed by "click here", in a new window, would i get the same session (since it would have the jsessionid appended).

So if i am shopping on amazon.com and have my shopping cart with 3 items, and i open a new window and type www.amazon.com, i will not see these items at all (if cookies are disabled and url rewriting is used). However, if i try to open a new window by clicking a link in the previous window, the items (session) would be remembered.


PS:- I used getKookies(), because i wasn't allowed to post with "C", ranch filters thought the post had "malicious" code .
[ May 20, 2007: Message edited by: swarna dasa ]
Pretty interesting....

Couldn't resist, so tried the following :-

Servlet code


JSP code (partial code)

<H2>Session is <%=request.getSession().getId()%></H2>

Browser - Mozilla Firefox v2.0.0.3
Web Container - Tomcat 5.0

Here is the Servlet Output
Case 1:- Enable cookies

a) First request sent:-

Output
Cookies are
New session 4C588E2FA3F77AC307459A557C6477D4 expires after 1800

b) Second request sent (new browser - Firefox new window)

Output
Cookies are
JSESSIONID 4C588E2FA3F77AC307459A557C6477D4
Old session 4C588E2FA3F77AC307459A557C6477D4 expires after 1800

Case 2:- Disable cookies (To be safe, block cookies from localhost )

a) First request sent:-

Output
Cookies are
New session 31747F37B0977622039AE913EF0A3D8B expires after 1800

b) Second Request sent:-

Output
Cookies are
New session A1F1556085377304BE8EB9D555EE0555 expires after 1800

When the servlet redirects to Result.jsp, i see the sessionid appended to the URL, but now when we open a new window and say
"http://localhost/beer/Result.jsp" a new session is created. (since jsessionid is NOT appended), but would the user ever append the session id? Dont think so.

So how does URL rewriting work?
[ May 19, 2007: Message edited by: swarna dasa ]
Have you tried after correcting your html file and web.xml?

When there is a problem with web.xml then your BeerV1 web application is not loaded, hence you get a 404 error on trying to access the form1.html.

Also, it is a good idea to run tomcat from command prompt using startup.bat/ startup.sh... you will see any exceptions due to web.xml on the command prompt.

Change your files and restart tomcat, you should be fine
My experience - when you try to review an answered Drag & Drop question then you get a pop up saying that "you have already answered the question and in case you wish to continue, you will have to answered the question again , do you want to continue? (with Yes No options) or something like that....
16 years ago