JSP基础6

<%@ page contentType="text/html; Charset=gb2312" language="java" import="java.util.*" errorPage="" %>
<html>
<head>
  <title>JSP练习</title>
</head>

<body>

<form action="b.jsp" method="post" name="frmName">
   <font color="black" size="3">
   <br>选择一幅图像:
       <select name="img">
           <option value="images/love.jpg" selected>人物</option>
           <option value="images/wife.jpg">爱人</option>
           <option value="images/xx.jpg">小侄子</option>
       </select>
   <br>选择视频或音乐:
       <select name="video">
           <option value="a.wmv">茉莉花</option>
           <option value="b.wmv">动画片</option>
           <option value="c.wmv">飞翔的鸽子</option>
       </select>  
   <br><input type="submit" value="提交" name="submit">      
   </font>
</form> 
</body>
</html>



<%@ page contentType="text/html; Charset=gb2312"%>
<html>
<head>

<title>Jsp练习</title>
</head>

<%! 
    public String getGBString(String src){
        try{
           if (src == null) return null;
           else{
               src = new String(src.getBytes("ISO-8859-1"), "GBK");
               return src;
           }
        }
        catch (Exception e){
            return null;
        } 
    }      
%>
<body>
<%
    String img = request.getParameter("img");
    String video = request.getParameter("video");
    if (img == null){
        img = "images/love.jpg";
    }
    if (video == null){
        video = "a.wmv";
    }
%>
    <img src="<%=img%>" width="120" height="120">图像</img>
    <embed src="<%=video%>" width="120" height="120">视频</embed>
</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值