• Post Reply Bookmark Topic Watch Topic
  • New Topic

Query string? In HTML, what is that?  RSS feed

 
william chaple
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi is this pretty much saying add a form that will save whatever you submit in the form (going to have a submit button) to save it in a query string?



Add a form with a text element and a submit button.
Initialize the text element with the corresponding value from the query string.




Ok I edit this; I researched and understand it more or less. This is what I have





I have a separate folder that I am trying to input what I put inside the form box.

So lets say I input "this is a great Poem" I want that input to show on the Poem.jsp page after pressing the send button. How do I do that?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
william chaple wrote: I want that input to show on the Poem.jsp page after pressing the send button. How do I do that?


I do not believe that this is what the instructor is asking for. I believe he is asking you to populate the text field with its previous value. So if you enter "fred" and click submit (I assume that the page is submitting to itself?), the text field will contain "fred" again.

The query string is how request parameters are passed to the target resource when a GET is used. It is appended to the URL.

In a JSP, there is an Expression Language builtin variable to obtain request parameters. I'll leave it to you to look up what it is named.

To set the value of a form element such as a text fielde, use the value attribute.
 
william chaple
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
william chaple wrote: I want that input to show on the Poem.jsp page after pressing the send button. How do I do that?


I do not believe that this is what the instructor is asking for. I believe he is asking you to populate the text field with its previous value. So if you enter "fred" and click submit (I assume that the page is submitting to itself?), the text field will contain "fred" again.

The query string is how request parameters are passed to the target resource when a GET is used. It is appended to the URL.

In a JSP, there is an Expression Language builtin variable to obtain request parameters. I'll leave it to you to look up what it is named.

To set the value of a form element such as a text fielde, use the value attribute.




Yeah Ive been trying that.

All my coding is in index.jsp but before I submit it the same page, null just is there.

this is my code it works just null is displayed which makes it look ugly lol i tried to find something but nothing comes up



but when I hit the submit button

fsaw.JPG
[Thumbnail for fsaw.JPG]
HTML//NULL
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you not allowed to use the Expression Language? Scriptlets are over 12 years out-of-date (but still taught, alas).

If you are allowed to use the EL, it automatically handles the nulls. If your instructor insists on you using scriptlets, you'll need to check for the nulls. (The ternary operator is useful for that.)
 
william chaple
Ranch Hand
Posts: 135
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Are you not allowed to use the Expression Language? Scriptlets are over 12 years out-of-date (but still taught, alas).

If you are allowed to use the EL, it automatically handles the nulls. If your instructor insists on you using scriptlets, you'll need to check for the nulls. (The ternary operator is useful for that.)



Oh I am way ahead in class. This is not even an assignment lol. I am just doing this to learn.
So I am a bit lost what to use? I am not sure what you mean. Can you show a piece of code or an example?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like your initiative.

Scriptlets (Java code in a JSP -- anything that uses the <% notation) have been obsolete since the introduction of the Expression Language and JSTL (JSP Standard Tag Library) back in 2001.

You should find a resource on modern JSP that emphasizes the EL and JSTL.

By the way, I always recommend that newcomers to JSP read:
  • The Secret Life of JSPs
  • The Front Man

  • The first explains what JSP is really all about, and the second, a tad more advanced, how to structure modern Java web applications.

     
    william chaple
    Ranch Hand
    Posts: 135
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Bear Bibeault wrote:I like your initiative.

    Scriptlets (Java code in a JSP -- anything that uses the <% notation) have been obsolete since the introduction of the Expression Language and JSTL (JSP Standard Tag Library) back in 2001.

    You should find a resource on modern JSP that emphasizes the EL and JSTL.

    By the way, I always recommend that newcomers to JSP read:
  • The Secret Life of JSPs
  • The Front Man

  • The first explains what JSP is really all about, and the second, a tad more advanced, how to structure modern Java web applications.



    so pretty much anything that uses <% %> is scriplets/servlets?

    so, EL is more used now pretty much?
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 65833
    134
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yes, and yes.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!